From d94bb110a60ccdbe98a1f4eb0034d20728f23ea8 Mon Sep 17 00:00:00 2001 From: Evan Fiordeliso Date: Sat, 12 Aug 2023 13:38:58 -0400 Subject: [PATCH] Better docker-build script --- devenv.nix | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/devenv.nix b/devenv.nix index a49334b..39e0ab9 100644 --- a/devenv.nix +++ b/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), "