Skip to content

Instantly share code, notes, and snippets.

@veggiemonk veggiemonk/Dockerfile
Last active Jul 11, 2019

Embed
What would you like to do?
Build GO app in multi-stage container
FROM golang:alpine AS builder
ENV TERRAGRUNT_VERSION=0.19.8 \
TERRAGRUNT_VERSION_SHA256SUM=70e81e5cc7a7c504557103e2ba90ac4c3c90a01bceffb2a34d4419643cf09998 \
TERRAFORM_VERSION=0.12.3 \
TERRAFORM_VERSION_SHA256SUM=75e4323b8514074f8c2118ea382fc677c8b1d1730eda323ada222e0fac57f7db
WORKDIR /go/src/github.com/runatlantis/atlantis/
RUN apk --no-cache add \
curl \
git \
dep \
ca-certificates \
make \
unzip \
&& curl https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip > terraform_linux_amd64.zip \
&& echo "${TERRAFORM_VERSION_SHA256SUM} terraform_linux_amd64.zip" > terraform_SHA256SUMS \
&& sha256sum -c terraform_SHA256SUMS \
&& unzip terraform_linux_amd64.zip \
&& curl -sSL https://github.com/gruntwork-io/terragrunt/releases/download/v${TERRAGRUNT_VERSION}/terragrunt_linux_amd64 > terragrunt \
&& echo "${TERRAGRUNT_VERSION_SHA256SUM} terragrunt" > terragrunt_SHA256SUMS \
&& sha256sum -c terragrunt_SHA256SUMS
COPY . .
RUN make build-service
FROM alpine:3.10
ARG CLOUD_SDK_VERSION=253.0.0
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH
COPY --from=builder /go/src/github.com/runatlantis/atlantis/terraform /usr/local/bin/terraform
COPY --from=builder /go/src/github.com/runatlantis/atlantis/terragrunt /usr/local/bin/terragrunt
COPY --from=builder /go/src/github.com/runatlantis/atlantis/atlantis /usr/local/bin/atlantis
RUN apk --no-cache add \
curl \
python \
py-crcmod \
bash \
libc6-compat \
openssh-client \
git \
gnupg \
ca-certificates \
&& curl -OL https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& tar xzf google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& rm google-cloud-sdk-${CLOUD_SDK_VERSION}-linux-x86_64.tar.gz \
&& ln -s /lib /lib64 \
&& gcloud components install beta \
&& gcloud components install kubectl \
&& gcloud config set core/disable_usage_reporting true \
&& gcloud config set component_manager/disable_update_check true \
&& gcloud config set metrics/environment github_docker_image \
&& gcloud --version
COPY cloudrun-docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["server"]
FROM golang:alpine AS builder
ARG GITHUB_USER
ARG REPO_NAME
WORKDIR /go/src/github.com/$GITHUB_USER/$REPO_NAME/
COPY . .
RUN apk add --no-cache \
curl \
git \
dep \
&& dep ensure \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o $REPO_NAME .
FROM alpine:3.10
RUN apk add --no-cache ca-certificates
COPY --from=builder /go/src/github.com/$GITHUB_USER/$REPO_NAME/$REPO_NAME /bin/$REPO_NAME
ENTRYPOINT ["/bin/$REPO_NAME"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.