From 785ee68a7679efb91c62bf4a342566b0f977914d Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 25 Oct 2018 17:49:46 +1100 Subject: [PATCH] Improved docker build process --- Dockerfile | 5 ++++- release_instructions.txt | 1 + scripts/publish-docker.sh | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 scripts/publish-docker.sh diff --git a/Dockerfile b/Dockerfile index c89f0ec1..b82fac25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,12 @@ RUN CGO_ENABLED=0 make local build # Choose alpine as a base image to make this useful for CI, as many # CI tools expect an interactive shell inside the container -FROM alpine:3.7 +FROM alpine:3.7 as production COPY --from=builder /go/src/mikefarah/yq/yq /usr/bin/yq RUN chmod +x /usr/bin/yq +ARG VERSION=none +LABEL version=${VERSION} + WORKDIR /workdir diff --git a/release_instructions.txt b/release_instructions.txt index 1e45b2c8..db873d8f 100644 --- a/release_instructions.txt +++ b/release_instructions.txt @@ -25,6 +25,7 @@ - docker - build and push latest and new version tag + - docker build . --arg -t mikefarah/yq:latest -t mikefarah/yq:VERSION - debian package - execute diff --git a/scripts/publish-docker.sh b/scripts/publish-docker.sh new file mode 100755 index 00000000..315eb197 --- /dev/null +++ b/scripts/publish-docker.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -ex +VERSION="$(git describe --tags --abbrev=0)" +docker build \ + --target production \ + --build-arg VERSION=${VERSION} \ + -t mikefarah/yq:latest \ + -t mikefarah/yq:${VERSION} \ + . \ No newline at end of file