build(v3): use pnpm, docker, docker-compose to orchestrate two services (client, server)

This commit is contained in:
Amruth Pillai
2022-03-07 13:43:34 +01:00
parent 9c1380f401
commit 938e2e8e25
23 changed files with 9355 additions and 11409 deletions

51
client/Dockerfile Normal file
View File

@ -0,0 +1,51 @@
FROM node:16-alpine as dependencies
RUN apk add --no-cache curl g++ make python3 \
&& curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
WORKDIR /app
COPY package.json pnpm-*.yaml ./
COPY ./schema/package.json ./schema/package.json
COPY ./client/package.json ./client/package.json
RUN pnpm install --frozen-lockfile
FROM node:16-alpine as builder
RUN apk add --no-cache curl g++ make python3 \
&& curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
WORKDIR /app
COPY . .
COPY --from=dependencies /app/node_modules ./node_modules
COPY --from=dependencies /app/schema/node_modules ./schema/node_modules
COPY --from=dependencies /app/client/node_modules ./client/node_modules
RUN cp .env ./client/.env
RUN pnpm run build:schema
RUN pnpm run build:client
FROM node:16-alpine as production
WORKDIR /app
RUN apk add --no-cache curl \
&& curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm
COPY --from=builder /app/pnpm-*.yaml .
COPY --from=builder /app/package.json .
COPY --from=builder /app/client/.next ./client/.next
COPY --from=builder /app/client/public ./client/public
COPY --from=builder /app/client/next.config.js ./client/next.config.js
COPY --from=builder /app/client/next-i18next.config.js ./client/next-i18next.config.js
COPY --from=builder /app/client/package.json ./client/package.json
RUN pnpm install -F client --frozen-lockfile --prod
EXPOSE 3000
CMD [ "pnpm", "run", "start:client" ]