From 512d4f20039cbda7030de2397c09a782792feb1e Mon Sep 17 00:00:00 2001 From: lbaf23 <2282480289@qq.com> Date: Sat, 24 Jul 2021 15:58:55 +0800 Subject: [PATCH] fix: dockerfile --- Dockerfile | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7c70b86..f3b451c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,27 @@ -FROM node:lts-alpine as front-end -WORKDIR /openpbl-landing -COPY openpbl-landing/package.json package.json -RUN yarn install -COPY openpbl-landing/. . -RUN set NODE_OPTIONS=--max_old_space_size=2048 -RUN yarn build +FROM golang:1.16-rc-buster +WORKDIR /openpbl +COPY ./ /openpbl +RUN go env -w CGO_ENABLED=0 GOPROXY=https://goproxy.io,direct GOOS=linux GOARCH=amd64 \ + && apt update && apt install sudo \ + && wget https://nodejs.org/dist/v12.22.0/node-v12.22.0-linux-x64.tar.gz \ + && sudo tar xf node-v12.22.0-linux-x64.tar.gz \ + && sudo apt install wait-for-it +ENV PATH=$PATH:/openpbl/node-v12.22.0-linux-x64/bin +RUN npm install -g yarn \ + && cd openpbl-landing \ + && yarn install \ + && yarn run build \ + && rm -rf node_modules \ + && cd /openpbl \ + && go build main.go - -FROM golang:alpine3.13 +FROM alpine:3.7 ENV RUNMODE=prod -WORKDIR /OpenPBL -RUN go env -w GO111MODULE=on ;go env -w GOPROXY=https://goproxy.cn,direct -RUN apk add --update alpine-sdk -COPY go.mod . -RUN go mod download -COPY . . -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories -COPY --from=front-end /openpbl-landing/build openpbl-landing/build -RUN go build -ENTRYPOINT ["./OpenPBL"] +COPY --from=0 /openpbl / +COPY --from=0 /usr/bin/wait-for-it / +RUN set -eux \ + && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories \ + && apk update \ + && apk upgrade \ + && apk add bash +CMD ./wait-for-it db:3306 && ./main \ No newline at end of file