dockerized the app successfully

This commit is contained in:
Nabil Ould Hamou 2024-12-18 09:38:42 +01:00
parent 0fbbecc1d1
commit 38f33881e0
8 changed files with 42 additions and 3745 deletions

View file

@ -1,13 +1,13 @@
# Build stage # Build stage
FROM node:18.18-alpine FROM node:18.18-alpine
WORKDIR /app
COPY . .
RUN npm i -g pnpm RUN npm i -g pnpm
EXPOSE 3000 EXPOSE 3000
ENV NODE_ENV=production
COPY . /app RUN chmod +x /app/docker_entrypoint.sh
ENTRYPOINT ["/app/docker_entrypoint.sh"]
WORKDIR /app
CMD docker_entrypoint.sh

View file

@ -1,5 +1,22 @@
services: services:
app:
build: .
hostname: app
depends_on:
- mongodb
- redis
environment:
- DATABASE_URL=mongodb://temp-root-username:temp-password@mongodb/chat_projetweb?authSource=admin
- JWT_SECRET=ba63466f102443f4bb6f3670891358bc4488d0c717f6ebcd3ee3c5144e55fe2d
ports:
- "3000:3000"
networks:
- app_network
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
mongodb: mongodb:
build: ./mongodb_rs build: ./mongodb_rs
hostname: mongodb hostname: mongodb
@ -8,7 +25,7 @@ services:
- MONGO_INITDB_ROOT_USERNAME=temp-root-username - MONGO_INITDB_ROOT_USERNAME=temp-root-username
- MONGO_INITDB_ROOT_PASSWORD=temp-password - MONGO_INITDB_ROOT_PASSWORD=temp-password
- MONGO_INITDB_DATABASE=chat_projetweb - MONGO_INITDB_DATABASE=chat_projetweb
- MONGO_REPLICA_HOST=localhost - MONGO_REPLICA_HOST=mongodb
- MONGO_REPLICA_PORT=27017 - MONGO_REPLICA_PORT=27017
ports: ports:
- "27017:27017" - "27017:27017"

View file

@ -5,8 +5,9 @@ pnpm install
pnpm prisma generate pnpm prisma generate
pnpm run build pnpm run build
pnpm prune --prod
pnpx prisma db push pnpx prisma db push
node build/index.js ls
node build

View file

@ -32,11 +32,11 @@
"tailwind-variants": "^0.3.0", "tailwind-variants": "^0.3.0",
"tailwindcss": "^3.4.9", "tailwindcss": "^3.4.9",
"typescript": "^5.0.0", "typescript": "^5.0.0",
"typescript-eslint": "^8.0.0", "typescript-eslint": "^8.0.0"
"vite": "^5.0.3"
}, },
"dependencies": { "dependencies": {
"@prisma/client": "^5.22.0", "@prisma/client": "^5.22.0",
"@sveltejs/adapter-node": "^5.2.10",
"@types/jsonwebtoken": "^9.0.7", "@types/jsonwebtoken": "^9.0.7",
"@types/node": "^22.10.1", "@types/node": "^22.10.1",
"argon2": "^0.41.1", "argon2": "^0.41.1",
@ -48,6 +48,7 @@
"socket.io": "^4.8.1", "socket.io": "^4.8.1",
"socket.io-client": "^4.8.1", "socket.io-client": "^4.8.1",
"svelte-radix": "^2.0.1", "svelte-radix": "^2.0.1",
"vite": "^5.0.3",
"winston": "^3.17.0" "winston": "^3.17.0"
} }
} }

3722
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -5,8 +5,8 @@
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
generator client { generator client {
provider = "prisma-client-js" provider = "prisma-client-js"
binaryTargets = ["debian-openssl-1.1.x", "linux-musl-openssl-3.0.x"] binaryTargets = ["debian-openssl-1.1.x", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"]
} }
datasource db { datasource db {
@ -15,14 +15,14 @@ datasource db {
} }
model User { model User {
id String @id @default(auto()) @map("_id") @db.ObjectId id String @id @default(auto()) @map("_id") @db.ObjectId
username String @unique username String @unique
profilePicture String @default("default.png") profilePicture String @default("default.png")
surname String surname String
name String name String
email String @unique email String @unique
password String password String
messages Message[] messages Message[]
@@map("users") // Table name in DB @@map("users") // Table name in DB
} }

View file

@ -1,7 +1,7 @@
import { createClient } from 'redis'; import { createClient } from 'redis';
const client = await createClient({ const client = await createClient({
url: process.env.REDIS_URL || 'redis://localhost:6379' url: process.env.REDIS_URL || 'redis://redis-server:6379'
}); });

View file

@ -1,5 +1,5 @@
import { mdsvex } from 'mdsvex'; import { mdsvex } from 'mdsvex';
import adapter from '@sveltejs/adapter-auto'; import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */