From eb083ed6de0634a290c9733169e0bd3bab5557b5 Mon Sep 17 00:00:00 2001 From: Chris Swan <478926+cpswan@users.noreply.github.com> Date: Thu, 24 Jun 2021 09:58:51 +0100 Subject: [PATCH] Two stage Dockerfile for atsigncompany/filebin2 --- .github/workflows/docker-image.yml | 2 +- Dockerfile.prod | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 Dockerfile.prod diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2fa20796..86d58b2c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -22,7 +22,7 @@ jobs: id: docker_build uses: docker/build-push-action@v2.5.0 with: - file: ./Dockerfile + file: ./Dockerfile.prod push: true tags: | atsigncompany/filebin2:automated diff --git a/Dockerfile.prod b/Dockerfile.prod new file mode 100644 index 00000000..33665afa --- /dev/null +++ b/Dockerfile.prod @@ -0,0 +1,29 @@ +FROM golang:buster AS build +RUN export DEBIAN_FRONTEND=noninteractive && \ + apt-get install -y make gcc libc-dev git +WORKDIR /app +RUN go get -u github.com/jstemmer/go-junit-report +RUN go get -u github.com/GeertJohan/go.rice/rice +COPY . . +RUN go build -tags netgo -ldflags '-extldflags "-static"' + +FROM debian:stable-slim +ENV HOMEDIR=/home/filebin2 +ENV USER_ID=1024 +ENV GROUP_ID=1024 +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install ca-certificates -y && \ + update-ca-certificates && \ + mkdir -p $HOMEDIR && \ + mkdir -p /var/log/filebin && \ + addgroup --gid $GROUP_ID filebin2 && \ + useradd --system --uid $USER_ID --gid $GROUP_ID --shell /bin/bash \ + --home $HOMEDIR filebin2 && \ + chown -R filebin2:filebin2 $HOMEDIR && \ + chown -R filebin2:filebin2 /var/log/filebin +COPY --from=build --chown=filebin2:filebin2 /app/filebin2 \ + /usr/local/bin/filebin2 +WORKDIR $HOMEDIR +USER filebin2 +ENTRYPOINT ["/usr/local/bin/filebin2"] \ No newline at end of file