FROM node:12.16.1 as gva-web WORKDIR /gva_web/ COPY web/ . RUN npm install -g cnpm --registry=https://registry.npm.taobao.org RUN cnpm install || npm install RUN npm run build FROM golang:alpine as gva-server ENV GO111MODULE=on ENV GOPROXY=https://goproxy.io,direct WORKDIR /go/src/gin-vue-admin COPY server/ ./ RUN go env && go list && go build -o gva-server . FROM nginx:alpine LABEL MAINTAINER="SliverHorn" WORKDIR gva/ # copy web COPY --from=gva-web /gva_web/dist ./resource/dist # copy server COPY --from=gva-server /go/src/gin-vue-admin/gva-server ./ COPY --from=gva-server /go/src/gin-vue-admin/config.yaml ./ COPY --from=gva-server /go/src/gin-vue-admin/resource ./resource EXPOSE 8888 ENTRYPOINT ./gva-server # 根据Dockerfile生成Docker镜像 # docker build -t gva-server:1.0 . #- 根据Docker镜像启动Docker容器 # - 后台运行 # - ``` # docker run -d -p 8888:8888 --name gva-server-v1 gva-server:1.0 # ``` # - 以可交互模式运行, Ctrl + p + q # - ``` # docker run -it -p 8888:8888 --name gva-server-v1 gva-server:1.0 # ```