From a3dcc70e39089b6bedc25682c0420f91c2e779de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 11 Mar 2019 09:56:46 +0000 Subject: [PATCH] cmd/shfmt: add Docker image build files from v2 --- cmd/shfmt/Dockerfile | 8 ++++++++ release-docker.sh | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 cmd/shfmt/Dockerfile create mode 100755 release-docker.sh diff --git a/cmd/shfmt/Dockerfile b/cmd/shfmt/Dockerfile new file mode 100644 index 000000000..8b9709367 --- /dev/null +++ b/cmd/shfmt/Dockerfile @@ -0,0 +1,8 @@ +FROM golang:1.12-alpine3.9 + +COPY . /go/src/mvdan.cc/sh +RUN CGO_ENABLED=0 go install -ldflags '-w -s -extldflags "-static"' mvdan.cc/sh/cmd/shfmt + +FROM busybox:1.30.1-musl +COPY --from=0 /go/bin/shfmt /bin/shfmt +ENTRYPOINT ["/bin/shfmt"] diff --git a/release-docker.sh b/release-docker.sh new file mode 100755 index 000000000..41915ba00 --- /dev/null +++ b/release-docker.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +tag=$(git describe --exact-match 2>/dev/null) +if [[ $? != 0 ]]; then + tag=latest +fi + +docker build -t mvdan/shfmt:$tag -f cmd/shfmt/Dockerfile . + +if [[ -n $DOCKER_PASSWORD ]]; then + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin +fi + +docker push mvdan/shfmt:$tag