|
|
@@ -12,8 +12,8 @@ WORKDIR /go/release |
|
|
|
# 把全部文件添加到/go/release目录 |
|
|
|
ADD . . |
|
|
|
|
|
|
|
# 编译:把main.go编译成可执行的二进制文件,命名为zyos |
|
|
|
RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o zyos main.go |
|
|
|
# 编译:把main.go编译成可执行的二进制文件,命名为egg |
|
|
|
RUN GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -tags netgo -ldflags="-s -w" -installsuffix cgo -o egg main.go |
|
|
|
|
|
|
|
FROM ubuntu:xenial as prod |
|
|
|
LABEL maintainer="dengbiao" |
|
|
@@ -25,12 +25,12 @@ RUN rm -f /etc/localtime \ |
|
|
|
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ |
|
|
|
&& echo "Asia/Shanghai" > /etc/timezone |
|
|
|
# 在build阶段复制可执行的go二进制文件app |
|
|
|
COPY --from=build /go/release/zyos ./zyos |
|
|
|
COPY --from=build /go/release/egg ./egg |
|
|
|
|
|
|
|
COPY --from=build /go/release/etc/cfg.yml /var/zyos/cfg.yml |
|
|
|
COPY --from=build /go/release/etc/cfg.yml /var/egg/cfg.yml |
|
|
|
|
|
|
|
# 启动服务 |
|
|
|
# CMD ["./zyos","-c","/var/zyos/cfg.yml"] |
|
|
|
CMD ["bash","-c","sysctl -w net.ipv4.tcp_tw_reuse=1 && sysctl -w net.ipv4.tcp_fin_timeout=10 && sysctl -w net.ipv4.ip_local_port_range='1024 65535' && sysctl -p && ./zyos -c /var/zyos/cfg.yml"] |
|
|
|
# CMD ["./egg","-c","/var/egg/cfg.yml"] |
|
|
|
CMD ["bash","-c","sysctl -w net.ipv4.tcp_tw_reuse=1 && sysctl -w net.ipv4.tcp_fin_timeout=10 && sysctl -w net.ipv4.ip_local_port_range='1024 65535' && sysctl -p && ./egg -c /var/egg/cfg.yml"] |
|
|
|
|
|
|
|
|