gowebbuild/templates/docker_image.sh

19 lines
574 B
Bash
Raw Normal View History

2024-08-26 23:12:33 +02:00
#!/bin/bash
mkdir -p _build
cd _build
mkdir -p docker_out
rm -rf sources
git clone $(git remote get-url origin) sources
cd sources
git fetch --tags
ver=$(git describe --tags `git rev-list --tags --max-count=1`)
git checkout $ver
CGO_ENABLED=0 go build -ldflags="-s -w" -o ../{{.ProjectFolderName}} .
# A second run is needed to build the final image.
cd ..
2024-08-26 23:53:31 +02:00
docker build -f sources/Dockerfile --no-cache -t {{.GoModuleName}}:${ver} -t {{.GoModuleName}}:latest .
2024-08-26 23:12:33 +02:00
docker push {{.GoModuleName}}:${ver}
2024-08-26 23:53:31 +02:00
docker push {{.GoModuleName}}:latest
2024-08-26 23:12:33 +02:00
rm -rf sources {{.ProjectFolderName}}