yes?
Some checks failed
Deploy Backend / deploy (push) Failing after 29s
Deploy Website / deploy (push) Has been cancelled

This commit is contained in:
Lee 2024-10-04 22:55:24 +01:00
parent 1164b4358b
commit 5865d55392
8 changed files with 37 additions and 18 deletions

@ -1,17 +1,37 @@
FROM node:20-alpine3.17 # Stage 1: Builder
FROM node:20-alpine3.17 AS builder
# Install pnpm # Install pnpm globally
RUN npm install -g pnpm RUN npm install -g pnpm
ENV PNPM_HOME=/usr/local/bin ENV PNPM_HOME=/usr/local/bin
WORKDIR /app WORKDIR /app
# Copy necessary files for installation
COPY package.json* pnpm-lock.yaml* pnpm-workspace.yaml* ./ COPY package.json* pnpm-lock.yaml* pnpm-workspace.yaml* ./
COPY common ./common
COPY backend ./backend COPY backend ./backend
RUN pnpm install --filter backend # Install dependencies for all workspaces, including backend
RUN pnpm run build:backend RUN pnpm install
# Build the backend
RUN pnpm --filter backend build
# Stage 2: Runner
FROM node:20-alpine3.17 AS runner
WORKDIR /app
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/backend/dist ./dist
COPY --from=builder /app/backend/package.json ./backend/package.json
# Install production dependencies
RUN npm install -g pnpm && pnpm install --prod
# Expose the port your application runs on
EXPOSE 8080 EXPOSE 8080
CMD ["pnpm", "start:backend"] # Command to run your app
CMD ["node", "dist/main.js"]

@ -10,6 +10,7 @@
"start": "nest start" "start": "nest start"
}, },
"dependencies": { "dependencies": {
"@ssr/common": "workspace:*",
"@nestjs/common": "^10.0.0", "@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0", "@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0", "@nestjs/platform-express": "^10.0.0",
@ -17,7 +18,6 @@
"rxjs": "^7.8.1" "rxjs": "^7.8.1"
}, },
"devDependencies": { "devDependencies": {
"@ssr/common": "workspace:*",
"concurrently": "^9.0.1", "concurrently": "^9.0.1",
"nodemon": "^2.0.20", "nodemon": "^2.0.20",
"tsup": "^8.3.0", "tsup": "^8.3.0",

@ -2,7 +2,9 @@ import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module"; import { AppModule } from "./app.module";
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule, {
logger: ["error", "warn"],
});
await app.listen(8080); await app.listen(8080);
} }
bootstrap(); bootstrap();

2
common/.dockerignore Normal file

@ -0,0 +1,2 @@
node_modules
dist

@ -1,15 +1,10 @@
{ {
"name": "@ssr/common", "name": "@ssr/common",
"version": "1.0.0", "version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": { "scripts": {
"dev": "tsup src/index.ts --watch", "dev": "tsup src/index.ts --watch",
"build": "tsup src/index.ts" "build": "tsup src/index.ts"
}, },
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": { "devDependencies": {
"tsup": "^6.5.0", "tsup": "^6.5.0",
"typescript": "^5" "typescript": "^5"

@ -4,11 +4,11 @@
"scripts": { "scripts": {
"dev": "pnpm --parallel --workspace-concurrency=4 run -r dev", "dev": "pnpm --parallel --workspace-concurrency=4 run -r dev",
"build:website": "pnpm --filter website... build", "build:website": "pnpm --filter website build",
"build:backend": "pnpm --filter backend... build", "build:backend": "pnpm --filter backend build",
"start:website": "pnpm --filter website... start", "start:website": "pnpm --filter website start",
"start:backend": "pnpm --filter backend... start" "start:backend": "pnpm --filter backend start"
}, },
"author": "fascinated7", "author": "fascinated7",
"license": "MIT" "license": "MIT"

2
pnpm-lock.yaml generated

@ -36,7 +36,7 @@ importers:
specifier: ^10.0.0 specifier: ^10.0.0
version: 10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4)) version: 10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4(@nestjs/common@10.4.4(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4))
'@ssr/common': '@ssr/common':
specifier: workspace:* specifier: workspace:common
version: link:../common version: link:../common
'@types/express': '@types/express':
specifier: ^4.17.17 specifier: ^4.17.17

@ -1,4 +1,4 @@
packages: packages:
- "common"
- "website" - "website"
- "backend" - "backend"
- "common"