构建go项目docker最小镜像,顺带解决时区和证书问题

FROM alpine:latest as base
RUN apk update && apk add ca-certificates  \
    && echo "https://mirrors.aliyun.com/alpine/v3.8/main/" > /etc/apk/repositories \
    && echo "https://mirrors.aliyun.com/alpine/v3.8/community/" >> /etc/apk/repositories \
    && apk add --no-cache tzdata \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  \
    && echo Asia/Shanghai > /etc/timezone
FROM scratch
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs /etc/ssl/certs
ENV TZ=Asia/Shanghai
COPY . /
CMD ["/projectName"]

你可能感兴趣的:(golang,docker,开发语言)