Skip to content

Commit 94e9047

Browse files
authored
Improve the Dockerfile (#26)
* Dockerfile: Inline `APP_NAME` Since `merge-gatekeeper` is necessarily hard-coded in the entrypoint, there's little value in extracting it to an environment variable; if we changed it, the entrypoint wouldn't exist. This commit therefore inlines it. * Dockerfile: Declare env vars as args where possible We don't need `ORG` and `REPO` in the container environment. This commit therefore redefines them as build arguments. This has the side benefit of being able to change them at build time, which could be useful for people using forks of this repo. * Dockerfile: Combine env var definitions In order to reduce the number of image layers, this commit combines some environment variable definitions into a single step.
1 parent 9c28a31 commit 94e9047

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@ ARG GO_VERSION=1.16.7
22

33
FROM golang:${GO_VERSION}-alpine
44

5-
ENV GO111MODULE on
6-
ENV LANG en_US.UTF-8
7-
ENV ORG upsidr
8-
ENV REPO merge-gatekeeper
9-
ENV APP_NAME merge-gatekeeper
5+
ARG ORG=upsidr
6+
ARG REPO=merge-gatekeeper
7+
8+
ENV GO111MODULE=on LANG=en_US.UTF-8
109

1110
RUN mkdir -p $GOPATH/src
1211

1312
WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}
1413

1514
COPY . .
1615

17-
RUN CGO_ENABLED=0 go build ./cmd/${APP_NAME} \
18-
&& mv ${APP_NAME} /go/bin/
16+
RUN CGO_ENABLED=0 go build ./cmd/merge-gatekeeper \
17+
&& mv merge-gatekeeper /go/bin/
1918

2019
ENTRYPOINT ["/go/bin/merge-gatekeeper"]

0 commit comments

Comments
 (0)