From f9f2f549afc775c17aa0abd8a1fd9ba69ca48a47 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 18 Sep 2023 23:23:13 +0800 Subject: [PATCH] chore: update dockerfile --- Dockerfile | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 935eb141..331be9d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,22 @@ +# Build protobuf. +FROM golang:1.21-alpine AS protobuf +WORKDIR /protobuf-generate + +COPY . . + +RUN GO111MODULE=on GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/buf@v1.26.1 + +WORKDIR /protobuf-generate/proto + +RUN buf generate + # Build frontend dist. FROM node:18-alpine AS frontend WORKDIR /frontend-build -COPY . . +COPY ./web . -WORKDIR /frontend-build/proto - -RUN npm i -g @bufbuild/buf - -RUN buf generate - -WORKDIR /frontend-build/web +COPY --from=protobuf /protobuf-generate/web/src/types/proto ./src/types/proto RUN corepack enable && pnpm i --frozen-lockfile @@ -21,7 +27,7 @@ FROM golang:1.21-alpine AS backend WORKDIR /backend-build COPY . . -COPY --from=frontend /frontend-build/web/dist ./server/dist +COPY --from=frontend /frontend-build/dist ./server/dist RUN CGO_ENABLED=0 go build -o memos ./main.go