#前端预构建 # FROM cmfont-cache:latest as builderFont # COPY /client . # RUN cnpm run build # 后端预构建 #FROM cm-gocache:latest AS builder # FROM golang:1.15-alpine AS builder # RUN go env -w GO111MODULE=on # RUN go env -w GOPROXY=https://goproxy.cn,direct # COPY . /go/src/construction_management # # 编译 # WORKDIR /go/src/construction_management/web # RUN ls ./ # #install 执行文件会生成在 gopath/bin 中 # RUN go mod tidy # RUN go install ./ # # 正式镜像 # FROM alpine:3.13 # # 安装nginx # RUN echo http://mirrors.aliyun.com/alpine/v3.10/main>/etc/apk/repositories && \ # echo http://mirrors.aliyun.com/alpine/v3.10/community>>/etc/apk/repositories # RUN apk update && apk upgrade \ # && apk add nginx \ # && mkdir /run/nginx \ # && touch /run/nginx.pid && \ # # chmod 755 /run.sh && \ # apk del m4 autoconf make gcc g++ linux-headers # RUN find / -name ngnix.pid # # 复制配置文件和前端文件 # # COPY --from=builder /go/src/construction_management/deployment/default.conf /etc/nginx/conf.d # # COPY --from=builderFont /build /var/www/html/client # # 后端相关 # # 把编译环境中编译好的 chat 复制到生产镜像中的 bin/chat 文件名称 不是目录 # #COPY --from=builder /go/bin/chat /bin/chat # # /chat 放到根目录 # COPY --from=builder /go/bin/web /bin/server # COPY --from=builder /go/src/construction_management/server/web/config-debug.yaml /bin/config-debug.yaml # COPY --from=builder /go/src/construction_management/server/web/config-uat.yaml /bin/config-uat.yaml # COPY --from=builder /go/src/construction_management/server/web/config-pro.yaml /bin/config-pro.yaml # RUN mkdir -p /lib # COPY --from=builder /go/src/construction_management/server/lib/*.json /bin/lib/ # RUN chmod 777 /bin/lib/*.json # RUN chmod 777 /bin/server # RUN chmod 777 /bin/config-debug.yaml # RUN chmod 777 /bin/config-uat.yaml # RUN chmod 777 /bin/config-pro.yaml # ENV ADDR=:6060 # # 申明暴露的端口 # EXPOSE 80 # EXPOSE 6060 # # 设置服务入口 # # ENTRYPOINT ["/run.sh"] # 要放到bin 目录下才能运行 在 alpine 环境中 # ENTRYPOINT ["sh","-c", "/bin/server" ] FROM centos:7 # FROM alpine:3.13 # 要运行 centos中,可以放在随意的目录中运行 # COPY ./bin/construction_management / ADD /bin/ / RUN chmod 777 /construction_management RUN ls ENV PARAMS="" EXPOSE 6060 ENTRYPOINT ["sh","-c","/construction_management $PARAMS"]