Creating a dockerfile for golang with dep as the dependency manager



This is a sample dockerfile that you can use to build a docker image using dep as the package manager.


FROM golang:1.8 AS builder

ADD https://github.com/golang/dep/releases/download/v0.5.1/dep-linux-amd64 /usr/bin/dep
RUN chmod +x /usr/bin/dep

# Copy the code from the host and compile it

WORKDIR $GOPATH/src/github.com/appcoreopc/gTradeApp
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure --vendor-only
COPY . ./
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /app .

FROM scratch
COPY --from=builder /app ./
ENTRYPOINT ["./app"]

Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm