Compare commits

...

5 Commits

8 changed files with 72 additions and 8 deletions

12
.env.example Normal file
View File

@@ -0,0 +1,12 @@
# Host-side port for the API container (container port remains 3000)
API_HOST_PORT=3001
DATABASE_URL="postgresql://user:password@localhost:5432/nest_db"
JWT_SECRET="change_me_to_a_long_random_string"
PORT=3000
ADMIN_USERNAME="admin"
ADMIN_EMAIL="admin@example.com"
ADMIN_PASSWORD="change_me"
FRONT_ORIGIN="http://localhost:5173"
INTRA_ORIGIN="http://localhost:5174"

View File

@@ -49,7 +49,7 @@ npm install
### 3. Set Up Environment
Create `.env` files based on the examples in each project. See the main [README.md](./README.md) for required environment variables.
Create a root `.env` file from `.env.example` (`cp .env.example .env`) and adjust values as needed. See the main [README.md](./README.md) for required environment variables.
### 4. Create a Branch

View File

@@ -23,9 +23,11 @@ nest-intra/ # Staff-only internal portal (React + Vite)
### 1. Backend Setup
```bash
cd nest-backend
# from repository root
cp .env.example .env
# Edit .env with your database credentials
# Edit .env with your credentials
cd nest-backend
npm install
npm run db:push # Initialize database schema
npm run db:seed # Populate with sample data
@@ -35,6 +37,7 @@ npm run dev # Start dev server (http://localhost:3000)
#### Backend Environment Variables
```env
API_HOST_PORT=3001
DATABASE_URL="postgresql://user:password@localhost:5432/nest_db"
JWT_SECRET="your-secret-key"
PORT=3000

47
docker-compose.prod.yml Normal file
View File

@@ -0,0 +1,47 @@
services:
db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_DB: nest_db
POSTGRES_USER: nest_user
POSTGRES_PASSWORD: nest_password
volumes:
- db_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U nest_user -d nest_db"]
interval: 5s
timeout: 5s
retries: 5
api:
image: git.crowmate.fr/crowmate/nest-api:latest
restart: unless-stopped
ports:
- "${API_HOST_PORT:-3001}:3000"
environment:
DATABASE_URL: postgresql://nest_user:nest_password@db:5432/nest_db
depends_on:
db:
condition: service_healthy
front:
image: git.crowmate.fr/crowmate/nest-front:latest
restart: unless-stopped
ports:
- "5143:80"
environment:
API_URL: http://api:3000
depends_on:
- api
intra:
image: git.crowmate.fr/crowmate/nest-intra:latest
restart: unless-stopped
ports:
- "5174:5174"
depends_on:
- api
volumes:
db_data:

View File

@@ -18,9 +18,9 @@ services:
build: ./nest-backend
restart: unless-stopped
ports:
- "3000:3000"
- "${API_HOST_PORT:-3001}:3000"
env_file:
- ./nest-backend/.env
- ./.env
environment:
DATABASE_URL: postgresql://nest_user:nest_password@db:5432/nest_db
depends_on:

View File

@@ -28,4 +28,4 @@ COPY prisma ./prisma
EXPOSE 3000
CMD ["node", "dist/index.js"]
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/index.js"]

View File

@@ -18,7 +18,9 @@ services:
build: .
restart: unless-stopped
ports:
- "3000:3000"
- "${API_HOST_PORT:-3001}:3000"
env_file:
- ../.env
environment:
DATABASE_URL: postgresql://nest_user:nest_password@db:5432/nest_db
JWT_SECRET: ${JWT_SECRET:-change_me_in_production}

View File

@@ -13,6 +13,7 @@
},
"dependencies": {
"@prisma/client": "^5.22.0",
"prisma": "^5.22.0",
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
@@ -29,7 +30,6 @@
"@types/express": "^4.17.25",
"@types/jsonwebtoken": "^9.0.7",
"@types/node": "^22.7.5",
"prisma": "^5.22.0",
"ts-node": "^10.9.2",
"ts-node-dev": "^2.0.0",
"typescript": "^5.6.3"