dockerfile
- 沿着时间的轨迹,Docker 镜像构建走到了今天。追求又快又小的镜像已成为了 Docker 社区 的共识。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19FROM golang:1.9 as builder
WORKDIR /go/src/git.zituo.net/niu/UserService
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o UserServer .
FROM alpine:latest
LABEL maintainer = "happs.lives@gmail.com"
RUN apk --no-cache add ca-certificates tzdata \
&& cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone \
&& apk del tzdata
WORKDIR /root/UserService
COPY --from=builder /go/src/git.zituo.net/niu/UserService/UserServer .
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip
COPY --from=builder /go/src/git.zituo.net/niu/UserService/keys/ ./keys/
COPY --from=builder /go/src/git.zituo.net/niu/UserService/conf/ ./conf/
EXPOSE 8001
CMD [ "./UserServer" ]