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

47
server/Dockerfile Normal file
View File

@ -0,0 +1,47 @@
FROM node:16-alpine as dependencies
RUN apk add --no-cache g++ curl 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 ./server/package.json ./server/package.json
RUN pnpm install --frozen-lockfile
FROM node:16-alpine as builder
RUN apk add --no-cache g++ curl 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/server/node_modules ./server/node_modules
RUN cp .env ./server/.env
RUN pnpm run build:schema
RUN pnpm run build:server
FROM mcr.microsoft.com/playwright:focal as production
WORKDIR /app
RUN 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/server/dist ./server/dist
COPY --from=builder /app/server/package.json ./server/package.json
RUN pnpm install -F server --frozen-lockfile --prod
EXPOSE 3100
CMD [ "pnpm", "run", "start:server" ]

View File

@ -52,7 +52,6 @@
"devDependencies": {
"@nestjs/cli": "^8.2.2",
"@nestjs/schematics": "^8.0.7",
"@reactive-resume/schema": "workspace:^",
"@types/express": "^4.17.13",
"@types/multer": "^1.4.7",
"@types/node": "^17.0.21",
@ -63,6 +62,7 @@
"ts-node": "^10.7.0",
"tsconfig-paths": "^3.13.0",
"typescript": "<4.6.0",
"webpack": "^5.70.0"
"webpack": "^5.70.0",
"@reactive-resume/schema": "workspace:*"
}
}

View File

@ -3,7 +3,7 @@ import { ConfigService } from '@nestjs/config';
import { SchedulerRegistry } from '@nestjs/schedule';
import { mkdir, unlink, writeFile } from 'fs/promises';
import { nanoid } from 'nanoid';
import { join } from 'path';
import { join, resolve } from 'path';
import { PDFDocument } from 'pdf-lib';
import { Browser, chromium } from 'playwright-chromium';
@ -42,7 +42,7 @@ export class PrinterService implements OnModuleInit, OnModuleDestroy {
});
const pdf = await PDFDocument.create();
const directory = join(__dirname, 'assets', 'resumes');
const directory = resolve('dist/assets/resumes');
const filename = `RxResume_PDFExport_${nanoid()}.pdf`;
const publicUrl = `${serverUrl}/resumes/${filename}`;