Better docker-build script
This commit is contained in:
parent
70223a8040
commit
d94bb110a6
22
devenv.nix
22
devenv.nix
|
@ -27,8 +27,8 @@
|
|||
scripts.deps.exec = "go mod download";
|
||||
scripts.tidy.exec = "go mod tidy";
|
||||
|
||||
scripts.build-id = "git rev-parse --short HEAD";
|
||||
scripts.build-date = "date -Iseconds";
|
||||
scripts.build-id.exec = "git rev-parse --short HEAD";
|
||||
scripts.build-date.exec = "date -Iseconds";
|
||||
|
||||
scripts.build.exec = ''
|
||||
go build -ldflags="
|
||||
|
@ -53,18 +53,24 @@
|
|||
--platform $DOCKER_PLATFORMS
|
||||
'';
|
||||
|
||||
scripts.docker-build-release.exec = ''
|
||||
scripts.docker-build.exec = ''
|
||||
platform=''${1:-linux}
|
||||
output=''${2:-type=docker}
|
||||
|
||||
docker-init
|
||||
docker buildx build \
|
||||
docker buildx build . \
|
||||
--tag $(docker-image):$VERSION \
|
||||
--tag $(docker-image):latest \
|
||||
--platform $DOCKER_PLATFORMS \
|
||||
--platform $platform \
|
||||
--builder $NAME \
|
||||
--build-arg VERSION=$VERSION
|
||||
--build-arg BUILD=$(build-id)
|
||||
--build-arg BUILD_DATE=$(build-date)
|
||||
--build-arg VERSION=$VERSION \
|
||||
--build-arg BUILD=$(build-id) \
|
||||
--build-arg BUILD_DATE=$(build-date) \
|
||||
--output $output
|
||||
'';
|
||||
|
||||
scripts.docker-build-release.exec = "docker-build $DOCKER_PLATFORMS type=image,push=true";
|
||||
|
||||
enterShell = ''
|
||||
echo "Welcome to the $NAME development environment."
|
||||
echo -n "Golang version: $(go version | cut -d ' ' -f 3), "
|
||||
|
|
Loading…
Reference in New Issue