feat: setup docker compose
This commit is contained in:
parent
8b68d8a5cf
commit
bf96452f1b
|
|
@ -0,0 +1,129 @@
|
||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
target: development
|
||||||
|
container_name: banatie-app-dev
|
||||||
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
|
volumes:
|
||||||
|
- ./src:/app/src # Hot reload for development
|
||||||
|
- ./logs:/app/logs # Persistent logs
|
||||||
|
networks:
|
||||||
|
- banatie-dev
|
||||||
|
depends_on:
|
||||||
|
postgres:
|
||||||
|
condition: service_healthy
|
||||||
|
minio:
|
||||||
|
condition: service_healthy
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
env_file:
|
||||||
|
- .env.docker
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
container_name: banatie-postgres-dev
|
||||||
|
ports:
|
||||||
|
- "5433:5432" # Avoid conflicts with system PostgreSQL
|
||||||
|
volumes:
|
||||||
|
- ./data/postgres:/var/lib/postgresql/data
|
||||||
|
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/01-init.sql
|
||||||
|
networks:
|
||||||
|
- banatie-dev
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: banatie_db
|
||||||
|
POSTGRES_USER: banatie_user
|
||||||
|
POSTGRES_PASSWORD: development_password
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U banatie_user -d banatie_db"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
minio:
|
||||||
|
image: minio/minio:latest
|
||||||
|
container_name: banatie-minio-dev
|
||||||
|
ports:
|
||||||
|
- "9000:9000" # S3 API
|
||||||
|
- "9001:9001" # Web Console
|
||||||
|
volumes:
|
||||||
|
- ./data/minio:/data
|
||||||
|
networks:
|
||||||
|
- banatie-dev
|
||||||
|
environment:
|
||||||
|
MINIO_ROOT_USER: minioadmin
|
||||||
|
MINIO_ROOT_PASSWORD: minioadmin
|
||||||
|
command: server /data --console-address ":9001"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 3
|
||||||
|
start_period: 40s
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
minio-init:
|
||||||
|
image: minio/mc:latest
|
||||||
|
container_name: banatie-minio-init
|
||||||
|
networks:
|
||||||
|
- banatie-dev
|
||||||
|
depends_on:
|
||||||
|
minio:
|
||||||
|
condition: service_healthy
|
||||||
|
entrypoint: >
|
||||||
|
/bin/sh -c "
|
||||||
|
echo 'Setting up MinIO alias...';
|
||||||
|
mc alias set minio http://minio:9000 minioadmin minioadmin;
|
||||||
|
|
||||||
|
echo 'Creating demo bucket...';
|
||||||
|
mc mb --ignore-existing minio/banatie-demo;
|
||||||
|
|
||||||
|
echo 'Setting up public read policy for generated images...';
|
||||||
|
mc anonymous set download minio/banatie-demo/users/guest/generated;
|
||||||
|
|
||||||
|
echo 'Creating banatie service user...';
|
||||||
|
mc admin user add minio banatie-user banatie-password;
|
||||||
|
|
||||||
|
echo 'Attaching readwrite policy to banatie user...';
|
||||||
|
mc admin policy attach minio readwrite --user=banatie-user;
|
||||||
|
|
||||||
|
echo 'Creating lifecycle policy for temp files (7 days retention)...';
|
||||||
|
cat > /tmp/lifecycle.json << EOF
|
||||||
|
{
|
||||||
|
\"Rules\": [
|
||||||
|
{
|
||||||
|
\"ID\": \"temp-files-cleanup\",
|
||||||
|
\"Status\": \"Enabled\",
|
||||||
|
\"Filter\": {
|
||||||
|
\"Prefix\": \"users/\"
|
||||||
|
},
|
||||||
|
\"Expiration\": {
|
||||||
|
\"Days\": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
mc ilm import minio/banatie-demo < /tmp/lifecycle.json;
|
||||||
|
|
||||||
|
echo 'MinIO initialization completed successfully!';
|
||||||
|
exit 0;
|
||||||
|
"
|
||||||
|
restart: "no"
|
||||||
|
|
||||||
|
networks:
|
||||||
|
banatie-dev:
|
||||||
|
driver: bridge
|
||||||
|
name: banatie-dev-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
postgres-data:
|
||||||
|
driver: local
|
||||||
|
minio-data:
|
||||||
|
driver: local
|
||||||
Loading…
Reference in New Issue