|
|
FROM golang:1.16 as builder
|
|
|
ENV APP_DIR $GOPATH/src/go-stash
|
|
|
RUN mkdir -p $APP_DIR
|
|
|
WORKDIR $APP_DIR/
|
|
|
COPY ./stash stash
|
|
|
COPY ./go.mod go.mod
|
|
|
ENV GO111MODULE on
|
|
|
ENV GOPROXY https://goproxy.cn,direct
|
|
|
RUN go mod tidy
|
|
|
RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -o ./stash/go-stash ./stash
|
|
|
|
|
|
FROM alpine:latest
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
|
|
|
&& apk add --no-cache tzdata \
|
|
|
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
|
|
&& echo "Asia/Shanghai" > /etc/timezone \
|
|
|
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存
|
|
|
WORKDIR /root/
|
|
|
COPY --from=builder /go/src/go-stash/stash .
|
|
|
ENTRYPOINT ["./go-stash"] |
|
|
\ No newline at end of file |
...
|
...
|
|