Enhance Dockerfile configurations for API and frontend, including MySQL client installation, improved TypeScript build process, and a custom startup script for database migration. Update production environment example with refined database and application settings.
This commit is contained in:
99
docker-compose.production.yml
Normal file
99
docker-compose.production.yml
Normal file
@ -0,0 +1,99 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# MySQL Database
|
||||
scriptshare-db:
|
||||
image: mysql:8.0
|
||||
container_name: scriptshare-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-ScriptShare_Root_2024_Secure}
|
||||
MYSQL_DATABASE: ${DB_NAME:-scriptshare}
|
||||
MYSQL_USER: ${DB_USER:-scriptshare_user}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD:-ScriptShare_App_2024_Secure!}
|
||||
MYSQL_CHARSET: utf8mb4
|
||||
MYSQL_COLLATION: utf8mb4_unicode_ci
|
||||
volumes:
|
||||
- scriptshare_db_data:/var/lib/mysql
|
||||
- ./scripts/init-db.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
|
||||
ports:
|
||||
- "${DB_PORT:-3306}:3306"
|
||||
networks:
|
||||
- scriptshare-network
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-ScriptShare_Root_2024_Secure}"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 60s
|
||||
command: >
|
||||
--default-authentication-plugin=mysql_native_password
|
||||
--character-set-server=utf8mb4
|
||||
--collation-server=utf8mb4_unicode_ci
|
||||
--innodb-file-per-table=1
|
||||
--max-connections=200
|
||||
|
||||
# Backend API
|
||||
scriptshare-api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.api
|
||||
container_name: scriptshare-api
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- DATABASE_URL=mysql://${DB_USER:-scriptshare_user}:${DB_PASSWORD:-ScriptShare_App_2024_Secure!}@scriptshare-db:3306/${DB_NAME:-scriptshare}
|
||||
- JWT_SECRET=${JWT_SECRET:-production-super-secret-jwt-key-scriptshare-2024}
|
||||
- CORS_ORIGIN=${FRONTEND_URL:-http://localhost}
|
||||
- PORT=3000
|
||||
- DB_HOST=scriptshare-db
|
||||
- DB_PORT=3306
|
||||
- DB_USER=${DB_USER:-scriptshare_user}
|
||||
- DB_PASSWORD=${DB_PASSWORD:-ScriptShare_App_2024_Secure!}
|
||||
- DB_NAME=${DB_NAME:-scriptshare}
|
||||
ports:
|
||||
- "${API_PORT:-3001}:3000"
|
||||
networks:
|
||||
- scriptshare-network
|
||||
depends_on:
|
||||
scriptshare-db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 60s
|
||||
|
||||
# Frontend
|
||||
scriptshare-frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- VITE_APP_NAME=${APP_NAME:-ScriptShare}
|
||||
- VITE_APP_URL=${APP_URL:-http://localhost}
|
||||
- VITE_ANALYTICS_ENABLED=${ANALYTICS_ENABLED:-false}
|
||||
- VITE_API_URL=${API_URL:-http://localhost:3001}
|
||||
container_name: scriptshare-frontend
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${FRONTEND_PORT:-80}:80"
|
||||
networks:
|
||||
- scriptshare-network
|
||||
depends_on:
|
||||
- scriptshare-api
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
volumes:
|
||||
scriptshare_db_data:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
scriptshare-network:
|
||||
driver: bridge
|
Reference in New Issue
Block a user