014--docker编译go项目最小化

2018-11-04  本文已影响17人  糖纸疯了

1、参考网址

2、镜像打包

1、使用golang打出来的包太大了,非常占用内存300M+

FROM golang:latest
MAINTAINER Razil "niyuelin1990@163.com"
ENV GOPATH /apps/enzogo/
WORKDIR $GOPATH/src/enzoism/helloEnzo
ADD . $GOPATH/src/enzoism/helloEnzo
EXPOSE 6064
ENTRYPOINT  ["./helloEnzo"]

2、使用scratch进行打包操作只有30M+

FROM scratch
MAINTAINER enzo "https://github.com/enzoism"
ENV GOPATH /apps/enzogo/
WORKDIR /apps/enzogo/src/enzoism/helloEnzo
COPY . /apps/enzogo/src/enzoism/helloEnzo
ADD main /
ENTRYPOINT ["/main"]

3、最小化包的打包流程

FROM scratch
MAINTAINER enzo "https://github.com/enzoism"
ENV GOPATH /apps/enzogo/
WORKDIR /apps/enzogo/src/enzoism/helloEnzo
COPY . /apps/enzogo/src/enzoism/helloEnzo
ADD main /
ENTRYPOINT ["/main"]
上一篇 下一篇

猜你喜欢

热点阅读