正在显示
1 个修改的文件
包含
19 行增加
和
5 行删除
1 | -FROM golang:1.13 as build | 1 | +FROM golang:1.13 as builder |
2 | 2 | ||
3 | ENV GOPROXY https://goproxy.cn | 3 | ENV GOPROXY https://goproxy.cn |
4 | ENV GO111MODULE on | 4 | ENV GO111MODULE on |
5 | 5 | ||
6 | -WORKDIR /go/ability | 6 | +RUN git clone http://gitlab.fjmaimaimai.com/mmm-go/gocomm.git /app/gocomm |
7 | 7 | ||
8 | -ADD go.mod . | ||
9 | -ADD go.sum . | 8 | +WORKDIR /app/ability |
9 | + | ||
10 | +COPY go.mod . | ||
11 | +COPY go.sum . | ||
10 | RUN go mod download | 12 | RUN go mod download |
11 | 13 | ||
14 | +COPY . . | ||
15 | + | ||
12 | RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o ability main.go | 16 | RUN GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -installsuffix cgo -o ability main.go |
13 | 17 | ||
14 | -CMD ["/ability"] | ||
18 | +#FROM scratch | ||
19 | +FROM alpine:latest | ||
20 | +RUN apk add --no-cache tzdata \ | ||
21 | + && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | ||
22 | + && echo "Asia/Shanghai" > /etc/timezone \ | ||
23 | + && rm -rf /var/cache/apk/* /tmp/* /var/tmp/* $HOME/.cache ## 清除缓存 | ||
24 | +WORKDIR /root/ | ||
25 | +COPY --from=builder /app/ability . | ||
26 | +#RUN ls -l | ||
27 | +EXPOSE 8080 | ||
28 | +CMD ["./ability"] |
-
请 注册 或 登录 后发表评论