https://github.com/icowan/shorter/blob/master/Dockerfile

alpine golang 编译打包实例

FROM golang:1.13.4-alpine3.10 as build-env

ENV GO111MODULE=on
ENV BUILDPATH=github.com/icowan/shorter
ENV GOPROXY=https://goproxy.cn
ENV GOPATH=/go
RUN mkdir -p /go/src/${BUILDPATH}
COPY ./ /go/src/${BUILDPATH}
RUN cd /go/src/${BUILDPATH} && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install ./cmd/

FROM alpine:latest

RUN apk update \
        && apk upgrade \
        && apk add --no-cache \
        ca-certificates \
        curl \
        && update-ca-certificates 2>/dev/null || true

COPY --from=build-env /go/bin/cmd /go/bin/shorter
COPY ./dist /go/bin/dist

WORKDIR /go/bin/
CMD ["/go/bin/shorter", "-http-addr", ":8080"]
文档更新时间: 2020-03-02 09:35   作者:月影鹏鹏