Skip to content

Instantly share code, notes, and snippets.

@timjonesdev
Last active February 20, 2022 22:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save timjonesdev/14180cb3bdabde1781a1cd4a2be9a975 to your computer and use it in GitHub Desktop.
Save timjonesdev/14180cb3bdabde1781a1cd4a2be9a975 to your computer and use it in GitHub Desktop.
# ---------------------------------------------------------------------
# The first stage container, for building the application
# ---------------------------------------------------------------------
FROM golang:1.12.1-stretch as builder
COPY . /app
# Add the keys
ARG bitbucket_id
ENV bitbucket_id=$bitbucket_id
ARG bitbucket_token
ENV bitbucket_token=$bitbucket_token
WORKDIR /app/cmd/webapp
RUN git config \
--global \
url."https://${bitbucket_id}:${bitbucket_token}@privatebitbucket.com/".insteadOf \
"https://privatebitbucket.com/"
RUN GIT_TERMINAL_PROMPT=1 \
GOARCH=amd64 \
GOOS=linux \
CGO_ENABLED=0 \
go build -v --installsuffix cgo --ldflags="-s" -o myapp
# ---------------------------------------------------------------------
# The second stage container, for running the application
# ---------------------------------------------------------------------
FROM alpine:3.8
COPY --from=builder /app/cmd/webapp/myapp /app/myapp
WORKDIR /app
ENTRYPOINT ["/myapp"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment