fix build

This commit is contained in:
vchikalkin 2025-10-06 23:16:06 +03:00
parent 7fcf55abda
commit 17528d12c7
5 changed files with 92 additions and 78 deletions

View File

@ -1,45 +1,51 @@
# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker. ARG NODE_VERSION=22
# Make sure you update both files! ARG PROJECT=cache-proxy
FROM node:alpine AS builder # Alpine image
RUN corepack enable && corepack prepare pnpm@8.9.0 --activate FROM node:${NODE_VERSION}-alpine AS alpine
ENV PNPM_HOME=/usr/local/bin
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN apk update RUN apk update
# Set working directory RUN apk add --no-cache libc6-compat
FROM alpine as base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk add --no-cache libc6-compat && \
corepack enable && \
pnpm install turbo@2.3.2 dotenv-cli --global
FROM base AS pruner
ARG PROJECT
WORKDIR /app WORKDIR /app
RUN pnpm add -g turbo@1.12.4 dotenv-cli
COPY . . COPY . .
RUN turbo prune --scope=api --docker RUN turbo prune --scope=${PROJECT} --docker
# Add lockfile and package.json's of isolated subworkspace FROM base AS builder
FROM node:alpine AS installer
RUN corepack enable && corepack prepare pnpm@latest --activate
ENV PNPM_HOME=/usr/local/bin
RUN apk add --no-cache libc6-compat
RUN apk update
WORKDIR /app WORKDIR /app
# First install dependencies (as they change less often) COPY --from=pruner /app/out/json/ .
COPY .gitignore .gitignore COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/json/ . COPY --from=pruner /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
COPY --from=builder /app/out/pnpm-workspace.yaml ./pnpm-workspace.yaml RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --prod --frozen-lockfile
RUN pnpm install
COPY --from=pruner /app/out/full/ .
# Build the project and its dependencies
COPY --from=builder /app/out/full/ .
COPY turbo.json turbo.json COPY turbo.json turbo.json
RUN pnpm dotenv -e .env turbo run build --filter=api... COPY .env .env
RUN dotenv -e .env turbo run build --filter=${PROJECT}...
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm prune --prod --no-optional
RUN rm -rf ./**/*/src
FROM alpine AS runner
ARG PROJECT
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 appuser
USER appuser
FROM node:alpine AS runner
WORKDIR /app WORKDIR /app
COPY --from=builder --chown=nodejs:nodejs /app .
WORKDIR /app/apps/${PROJECT}
# Don't run production as root CMD ["node", "dist/main.js"]
RUN addgroup --system --gid 1001 nestjs
RUN adduser --system --uid 1001 nestjs
USER nestjs
COPY --from=installer /app .
CMD node apps/api/dist/main.js

View File

@ -20,39 +20,40 @@
"test:e2e": "jest --config ./test/jest-e2e.json" "test:e2e": "jest --config ./test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/cache-manager": "^2.2.1", "@nestjs/cache-manager": "^2.2.1",
"@nestjs/common": "^10.0.0", "@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.2.0", "@nestjs/config": "^3.2.0",
"@nestjs/core": "^10.0.0", "@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0", "@nestjs/platform-express": "^10.0.0",
"@nestjs/platform-fastify": "^10.3.3", "@nestjs/platform-fastify": "^10.3.3",
"@types/node": "catalog:",
"fastify": "^4.26.1",
"dotenv-cli": "catalog:",
"cache-manager": "^5.4.0", "cache-manager": "^5.4.0",
"cache-manager-ioredis": "^2.1.0", "cache-manager-ioredis": "^2.1.0",
"ioredis": "^5.3.2", "ioredis": "^5.3.2",
"reflect-metadata": "^0.2.0", "reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"source-map-support": "^0.5.21",
"tsconfig-paths": "^4.2.0",
"typescript": "catalog:",
"zod": "catalog:" "zod": "catalog:"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0", "@nestjs/testing": "^10.0.0",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*", "@repo/typescript-config": "workspace:*",
"@types/jest": "^29.5.2", "@types/jest": "^29.5.2",
"@types/node": "catalog:",
"@types/supertest": "^6.0.0", "@types/supertest": "^6.0.0",
"dotenv-cli": "catalog:",
"eslint": "catalog:", "eslint": "catalog:",
"fastify": "^4.26.1",
"jest": "^29.5.0", "jest": "^29.5.0",
"prettier": "catalog:", "prettier": "catalog:",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"ts-jest": "29.1.1", "ts-jest": "29.1.1",
"ts-loader": "^9.4.3", "ts-loader": "^9.4.3",
"ts-node": "^10.9.1", "ts-node": "^10.9.1"
"tsconfig-paths": "^4.2.0",
"typescript": "catalog:"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@ -6,7 +6,7 @@
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"target": "ES2021", "target": "ES2022",
"sourceMap": true, "sourceMap": true,
"outDir": "./dist", "outDir": "./dist",
"baseUrl": "./", "baseUrl": "./",
@ -18,5 +18,6 @@
"forceConsistentCasingInFileNames": false, "forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false "noFallthroughCasesInSwitch": false
}, },
"exclude": ["node_modules"] "include": ["."],
"exclude": ["dist", "build", "node_modules"]
} }

69
pnpm-lock.yaml generated
View File

@ -23,7 +23,7 @@ catalogs:
version: 2.2.2 version: 2.2.2
autoprefixer: autoprefixer:
specifier: ^10.4.20 specifier: ^10.4.20
version: 10.4.21 version: 10.4.20
dayjs: dayjs:
specifier: ^1.11.3 specifier: ^1.11.3
version: 1.11.13 version: 1.11.13
@ -35,7 +35,7 @@ catalogs:
version: 9.21.0 version: 9.21.0
graphql: graphql:
specifier: ^16.9.0 specifier: ^16.9.0
version: 16.11.0 version: 16.9.0
husky: husky:
specifier: ^9.1.7 specifier: ^9.1.7
version: 9.1.7 version: 9.1.7
@ -44,13 +44,13 @@ catalogs:
version: 9.0.2 version: 9.0.2
lint-staged: lint-staged:
specifier: ^15.2.10 specifier: ^15.2.10
version: 15.5.2 version: 15.2.10
lucide-react: lucide-react:
specifier: ^0.462.0 specifier: ^0.462.0
version: 0.462.0 version: 0.462.0
postcss: postcss:
specifier: ^8.4.49 specifier: ^8.4.49
version: 8.5.6 version: 8.4.49
postcss-load-config: postcss-load-config:
specifier: ^6.0.1 specifier: ^6.0.1
version: 6.0.1 version: 6.0.1
@ -59,7 +59,7 @@ catalogs:
version: 3.6.2 version: 3.6.2
radashi: radashi:
specifier: ^12.5.1 specifier: ^12.5.1
version: 12.6.0 version: 12.5.1
react: react:
specifier: ^19.1.1 specifier: ^19.1.1
version: 19.1.1 version: 19.1.1
@ -68,19 +68,19 @@ catalogs:
version: 19.1.1 version: 19.1.1
tailwindcss: tailwindcss:
specifier: ^3.4.15 specifier: ^3.4.15
version: 3.4.17 version: 3.4.15
typescript: typescript:
specifier: ^5.7 specifier: ^5.7
version: 5.8.3 version: 5.7.2
vite-tsconfig-paths: vite-tsconfig-paths:
specifier: ^5.1.4 specifier: ^5.1.4
version: 5.1.4 version: 5.1.4
vitest: vitest:
specifier: ^2.1.8 specifier: ^2.1.8
version: 2.1.9 version: 2.1.8
zod: zod:
specifier: ^3.24.1 specifier: ^3.24.1
version: 3.25.71 version: 3.24.1
importers: importers:
@ -193,6 +193,9 @@ importers:
'@nestjs/cache-manager': '@nestjs/cache-manager':
specifier: ^2.2.1 specifier: ^2.2.1
version: 2.3.0(@nestjs/common@10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.20)(cache-manager@5.7.6)(rxjs@7.8.1) version: 2.3.0(@nestjs/common@10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.20)(cache-manager@5.7.6)(rxjs@7.8.1)
'@nestjs/cli':
specifier: ^10.0.0
version: 10.4.9
'@nestjs/common': '@nestjs/common':
specifier: ^10.0.0 specifier: ^10.0.0
version: 10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1) version: 10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1)
@ -208,12 +211,24 @@ importers:
'@nestjs/platform-fastify': '@nestjs/platform-fastify':
specifier: ^10.3.3 specifier: ^10.3.3
version: 10.4.20(@nestjs/common@10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.20) version: 10.4.20(@nestjs/common@10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.20)
'@nestjs/schematics':
specifier: ^10.0.0
version: 10.2.3(chokidar@3.6.0)(typescript@5.7.2)
'@types/node':
specifier: 'catalog:'
version: 20.17.8
cache-manager: cache-manager:
specifier: ^5.4.0 specifier: ^5.4.0
version: 5.7.6 version: 5.7.6
cache-manager-ioredis: cache-manager-ioredis:
specifier: ^2.1.0 specifier: ^2.1.0
version: 2.1.0 version: 2.1.0
dotenv-cli:
specifier: 'catalog:'
version: 7.4.4
fastify:
specifier: ^4.26.1
version: 4.29.1
ioredis: ioredis:
specifier: ^5.3.2 specifier: ^5.3.2
version: 5.7.0 version: 5.7.0
@ -223,49 +238,43 @@ importers:
rxjs: rxjs:
specifier: ^7.8.1 specifier: ^7.8.1
version: 7.8.1 version: 7.8.1
source-map-support:
specifier: ^0.5.21
version: 0.5.21
tsconfig-paths:
specifier: ^4.2.0
version: 4.2.0
typescript:
specifier: 'catalog:'
version: 5.7.2
zod: zod:
specifier: 'catalog:' specifier: 'catalog:'
version: 3.24.1 version: 3.24.1
devDependencies: devDependencies:
'@nestjs/cli':
specifier: ^10.0.0
version: 10.4.9
'@nestjs/schematics':
specifier: ^10.0.0
version: 10.2.3(chokidar@3.6.0)(typescript@5.7.2)
'@nestjs/testing': '@nestjs/testing':
specifier: ^10.0.0 specifier: ^10.0.0
version: 10.4.20(@nestjs/common@10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.20)(@nestjs/platform-express@10.4.20) version: 10.4.20(@nestjs/common@10.4.20(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.20)(@nestjs/platform-express@10.4.20)
'@repo/eslint-config':
specifier: workspace:*
version: link:../../packages/eslint-config
'@repo/typescript-config': '@repo/typescript-config':
specifier: workspace:* specifier: workspace:*
version: link:../../packages/typescript-config version: link:../../packages/typescript-config
'@types/jest': '@types/jest':
specifier: ^29.5.2 specifier: ^29.5.2
version: 29.5.14 version: 29.5.14
'@types/node':
specifier: 'catalog:'
version: 20.17.8
'@types/supertest': '@types/supertest':
specifier: ^6.0.0 specifier: ^6.0.0
version: 6.0.3 version: 6.0.3
dotenv-cli:
specifier: 'catalog:'
version: 7.4.4
eslint: eslint:
specifier: 'catalog:' specifier: 'catalog:'
version: 9.21.0(jiti@2.4.1) version: 9.21.0(jiti@2.4.1)
fastify:
specifier: ^4.26.1
version: 4.29.1
jest: jest:
specifier: ^29.5.0 specifier: ^29.5.0
version: 29.7.0(@types/node@20.17.8)(ts-node@10.9.2(@types/node@20.17.8)(typescript@5.7.2)) version: 29.7.0(@types/node@20.17.8)(ts-node@10.9.2(@types/node@20.17.8)(typescript@5.7.2))
prettier: prettier:
specifier: 'catalog:' specifier: 'catalog:'
version: 3.6.2 version: 3.6.2
source-map-support:
specifier: ^0.5.21
version: 0.5.21
supertest: supertest:
specifier: ^6.3.3 specifier: ^6.3.3
version: 6.3.4 version: 6.3.4
@ -278,12 +287,6 @@ importers:
ts-node: ts-node:
specifier: ^10.9.1 specifier: ^10.9.1
version: 10.9.2(@types/node@20.17.8)(typescript@5.7.2) version: 10.9.2(@types/node@20.17.8)(typescript@5.7.2)
tsconfig-paths:
specifier: ^4.2.0
version: 4.2.0
typescript:
specifier: 'catalog:'
version: 5.7.2
apps/web: apps/web:
dependencies: dependencies:

View File

@ -13,7 +13,10 @@
"BOT_TOKEN", "BOT_TOKEN",
"NEXTAUTH_SECRET", "NEXTAUTH_SECRET",
"BOT_URL", "BOT_URL",
"BOT_PROVIDER_TOKEN" "BOT_PROVIDER_TOKEN",
"REDIS_HOST",
"REDIS_PORT",
"REDIS_PASSWORD"
] ]
}, },
"lint": { "lint": {