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.deps.exec = "go mod download";
|
||||||
scripts.tidy.exec = "go mod tidy";
|
scripts.tidy.exec = "go mod tidy";
|
||||||
|
|
||||||
scripts.build-id = "git rev-parse --short HEAD";
|
scripts.build-id.exec = "git rev-parse --short HEAD";
|
||||||
scripts.build-date = "date -Iseconds";
|
scripts.build-date.exec = "date -Iseconds";
|
||||||
|
|
||||||
scripts.build.exec = ''
|
scripts.build.exec = ''
|
||||||
go build -ldflags="
|
go build -ldflags="
|
||||||
|
@ -53,18 +53,24 @@
|
||||||
--platform $DOCKER_PLATFORMS
|
--platform $DOCKER_PLATFORMS
|
||||||
'';
|
'';
|
||||||
|
|
||||||
scripts.docker-build-release.exec = ''
|
scripts.docker-build.exec = ''
|
||||||
|
platform=''${1:-linux}
|
||||||
|
output=''${2:-type=docker}
|
||||||
|
|
||||||
docker-init
|
docker-init
|
||||||
docker buildx build \
|
docker buildx build . \
|
||||||
--tag $(docker-image):$VERSION \
|
--tag $(docker-image):$VERSION \
|
||||||
--tag $(docker-image):latest \
|
--tag $(docker-image):latest \
|
||||||
--platform $DOCKER_PLATFORMS \
|
--platform $platform \
|
||||||
--builder $NAME \
|
--builder $NAME \
|
||||||
--build-arg VERSION=$VERSION
|
--build-arg VERSION=$VERSION \
|
||||||
--build-arg BUILD=$(build-id)
|
--build-arg BUILD=$(build-id) \
|
||||||
--build-arg BUILD_DATE=$(build-date)
|
--build-arg BUILD_DATE=$(build-date) \
|
||||||
|
--output $output
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
scripts.docker-build-release.exec = "docker-build $DOCKER_PLATFORMS type=image,push=true";
|
||||||
|
|
||||||
enterShell = ''
|
enterShell = ''
|
||||||
echo "Welcome to the $NAME development environment."
|
echo "Welcome to the $NAME development environment."
|
||||||
echo -n "Golang version: $(go version | cut -d ' ' -f 3), "
|
echo -n "Golang version: $(go version | cut -d ' ' -f 3), "
|
||||||
|
|
Loading…
Reference in New Issue