Last active
February 20, 2022 22:01
-
-
Save timjonesdev/14180cb3bdabde1781a1cd4a2be9a975 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --------------------------------------------------------------------- | |
# 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