feat: Containerize the application with Docker and Docker Compose, including a PostgreSQL database and a deployment script.

This commit is contained in:
Moh Dzulfikri Maulana
2026-03-09 00:13:31 +07:00
parent bdd61d11d3
commit c7b022d502
6 changed files with 139 additions and 1 deletions

46
docker-compose.yml Normal file
View File

@@ -0,0 +1,46 @@
version: '3.8'
services:
db:
image: postgres:15-alpine
container_name: portfolio-db
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER:-fikri}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-fikri}
POSTGRES_DB: ${POSTGRES_DB:-fullstack-portfolio}
ports:
- "5429:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-fikri} -d ${POSTGRES_DB:-fullstack-portfolio}"]
interval: 5s
timeout: 5s
retries: 5
app:
build:
context: .
dockerfile: Dockerfile
container_name: portfolio-app
restart: always
ports:
- "4000:4000"
environment:
DATABASE_URL: postgresql://${POSTGRES_USER:-fikri}:${POSTGRES_PASSWORD:-fikri}@db:5432/${POSTGRES_DB:-fullstack-portfolio}?schema=public
JWT_SECRET: ${JWT_SECRET}
R2_TOKEN: ${R2_TOKEN}
R2_ACCESS_KEY: ${R2_ACCESS_KEY}
R2_SECRET_KEY: ${R2_SECRET_KEY}
R2_ENDPOINT: ${R2_ENDPOINT}
R2_BUCKET_NAME: ${R2_BUCKET_NAME}
IMAGE_URL: ${IMAGE_URL}
depends_on:
db:
condition: service_healthy
command: >
sh -c "npx prisma db push && node server.js"
volumes:
postgres_data: