Skip to content

Commit

Permalink
Improve the Dockerfile (#26)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
allanlewis authored Apr 11, 2022
1 parent 9c28a31 commit 94e9047
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ ARG GO_VERSION=1.16.7

FROM golang:${GO_VERSION}-alpine

ENV GO111MODULE on
ENV LANG en_US.UTF-8
ENV ORG upsidr
ENV REPO merge-gatekeeper
ENV APP_NAME merge-gatekeeper
ARG ORG=upsidr
ARG REPO=merge-gatekeeper

ENV GO111MODULE=on LANG=en_US.UTF-8

RUN mkdir -p $GOPATH/src

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

COPY . .

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

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

0 comments on commit 94e9047

Please sign in to comment.