Skip to content

Instantly share code, notes, and snippets.

@astericky
Created September 27, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astericky/79fa572eeadcfbd0a7dd1b3bea3bea11 to your computer and use it in GitHub Desktop.
Save astericky/79fa572eeadcfbd0a7dd1b3bea3bea11 to your computer and use it in GitHub Desktop.
# Run this from the parent directory
FROM golang:1.9-alpine as build_container
ENV APP_NAME my-app
ENV TARGET_DIR /go/src/github.com/MediaMath/${APP_NAME}
COPY . ${TARGET_DIR}
WORKDIR ${TARGET_DIR}
# Build app
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -a -o ${APP_NAME} .
FROM alpine:3.6
ENV APP_NAME my-app
ENV TARGET_DIR /go/src/github.com/MediaMath/${APP_NAME}
RUN apk update && apk upgrade && apk add --no-cache curl
RUN mkdir -p /app /app/config /app/views
WORKDIR /app
# Copy files from build_container to current container
COPY --from=build_container ${TARGET_DIR}/config/config.json config/
COPY --from=build_container ${TARGET_DIR}/${APP_NAME} .
ENTRYPOINT ["./my-app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment