Skip to content

Instantly share code, notes, and snippets.

@AmitDJagtap
Created December 15, 2018 12:57
Show Gist options
  • Save AmitDJagtap/b05e92c4df570cfcbdfdfc54e7139d29 to your computer and use it in GitHub Desktop.
Save AmitDJagtap/b05e92c4df570cfcbdfdfc54e7139d29 to your computer and use it in GitHub Desktop.
FROM golang:1.10 AS builder
# Download and install the latest release of dep
ADD https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep
# Copy the code from the host and compile it
WORKDIR /go/src/mygolangcode
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o ./dist/mygolangcode
FROM scratch
COPY --from=builder /go/src/lendingapi/dist/mygolangcode ./app
EXPOSE 8080
ENTRYPOINT ["./app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment