diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8d72f9e --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +BOT_TOKEN= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..612e596 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.env +.venv/ +__pycache__/ +*.pyc +node_modules/ +.next/ +*.log diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5d5e859 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,113 @@ +name: shop + +services: + postgres: + image: postgres:16-alpine + environment: + POSTGRES_USER: shop + POSTGRES_PASSWORD: shop + POSTGRES_DB: shop + volumes: + - pg_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U shop -d shop"] + interval: 5s + timeout: 3s + retries: 12 + restart: unless-stopped + + minio: + image: pgsty/silo:RELEASE.2026-10-26T00-00-00Z + command: server /data --console-address ":9001" + environment: + MINIO_ROOT_USER: minio + MINIO_ROOT_PASSWORD: minioadmin + volumes: + - minio_data:/data + ports: + - "9001:9001" + healthcheck: + test: ["CMD", "curl", "-f", "http://127.0.0.1:9000/minio/health/live"] + interval: 5s + timeout: 5s + retries: 20 + start_period: 10s + restart: unless-stopped + + api: + build: ./api + environment: + DATABASE_URL: postgresql+asyncpg://shop:shop@postgres:5432/shop + MINIO_ENDPOINT: minio:9000 + MINIO_ACCESS_KEY: minio + MINIO_SECRET_KEY: minioadmin + MINIO_BUCKET: products + MINIO_SECURE: "false" + BOT_SECRET: dev-bot-secret + COOKIE_SECURE: "false" + depends_on: + postgres: + condition: service_healthy + minio: + condition: service_healthy + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')"] + interval: 5s + timeout: 5s + retries: 12 + start_period: 20s + deploy: + replicas: 2 + restart: unless-stopped + + web: + build: + context: ./web + args: + API_INTERNAL_URL: http://api:8000 + environment: + API_INTERNAL_URL: http://api:8000 + HOSTNAME: 0.0.0.0 + PORT: "3000" + depends_on: + api: + condition: service_healthy + healthcheck: + test: ["CMD", "node", "-e", "fetch('http://127.0.0.1:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"] + interval: 5s + timeout: 5s + retries: 12 + start_period: 15s + deploy: + replicas: 2 + restart: unless-stopped + + bot: + build: ./bot + environment: + DATABASE_URL: postgresql://shop:shop@postgres:5432/shop + API_URL: http://api:8000 + BOT_TOKEN: ${BOT_TOKEN:-} + BOT_SECRET: dev-bot-secret + BOT_MODE: polling + depends_on: + api: + condition: service_healthy + deploy: + replicas: 2 + restart: unless-stopped + + gateway: + image: nginxinc/nginx-unprivileged:1.27-alpine + volumes: + - ./docker/nginx.conf:/etc/nginx/nginx.conf:ro + ports: + - "8088:8080" + depends_on: + web: + condition: service_healthy + restart: unless-stopped + +volumes: + pg_data: + minio_data: