Initial commit: stock market platform

This commit is contained in:
admin
2026-06-11 01:41:47 +08:00
commit 63718906e9
62 changed files with 8962 additions and 0 deletions

111
docker-compose.yml Normal file
View File

@@ -0,0 +1,111 @@
version: "3.9"
services:
postgres:
image: postgres:16-alpine
container_name: stock_postgres
environment:
POSTGRES_USER: ${POSTGRES_USER:-stock}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-stockpass}
POSTGRES_DB: ${POSTGRES_DB:-stockdb}
ports:
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U stock -d stockdb"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
container_name: stock_redis
command: redis-server --appendonly yes
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: stock_backend
env_file: .env
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-stock}:${POSTGRES_PASSWORD:-stockpass}@postgres:5432/${POSTGRES_DB:-stockdb}
REDIS_URL: redis://redis:6379/0
ports:
- "8000:8000"
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./backend:/app
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
celery_worker:
build:
context: ./backend
dockerfile: Dockerfile
container_name: stock_celery_worker
env_file: .env
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-stock}:${POSTGRES_PASSWORD:-stockpass}@postgres:5432/${POSTGRES_DB:-stockdb}
REDIS_URL: redis://redis:6379/0
CELERY_BROKER_URL: redis://redis:6379/1
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
volumes:
- ./backend:/app
command: celery -A celery_app.worker worker -l info -c 2
celery_beat:
build:
context: ./backend
dockerfile: Dockerfile
container_name: stock_celery_beat
env_file: .env
environment:
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-stock}:${POSTGRES_PASSWORD:-stockpass}@postgres:5432/${POSTGRES_DB:-stockdb}
REDIS_URL: redis://redis:6379/0
CELERY_BROKER_URL: redis://redis:6379/1
depends_on:
- celery_worker
volumes:
- ./backend:/app
command: celery -A celery_app.worker beat -l info --scheduler celery.beat:PersistentScheduler
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: stock_frontend
ports:
- "3000:80"
depends_on:
- backend
nginx:
image: nginx:alpine
container_name: stock_nginx
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- backend
- frontend
volumes:
postgres_data:
redis_data: