diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a715880 --- /dev/null +++ b/.env.example @@ -0,0 +1,10 @@ +# Copy this file to .env and update values for local development +# cp .env.example .env + +# Backend +DATABASE_URL=postgresql+psycopg://postgres:postgres@postgres:5432/zaban_backend_development +SECRET_KEY=your-local-secret-key +ALLOWED_HOSTS=localhost,127.0.0.1 + +# Frontend +NEXT_PUBLIC_EXTERNAL_API_URL=http://localhost:8000 diff --git a/.gitignore b/.gitignore index fb4cbdf..0c77806 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ # Environment variables .env -.env.local -.env.*.local # Docker docker-compose.override.yml diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml deleted file mode 100644 index 6e89807..0000000 --- a/docker-compose.prod.yml +++ /dev/null @@ -1,48 +0,0 @@ -# Production configuration with AWS RDS -# Usage: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d - -services: - # Disable local PostgreSQL (using RDS instead) - postgres: - image: alpine:latest - command: echo "Using external RDS database" - restart: "no" - deploy: - replicas: 0 - - # Backend - Production Configuration - backend: - environment: - DATABASE_URL: ${DATABASE_URL} - NODE_ENV: production - PYTHONUNBUFFERED: 1 - restart: always - deploy: - resources: - limits: - cpus: '2' - memory: 4G - reservations: - cpus: '1' - memory: 2G - depends_on: [] - volumes: - - /data/ml_models:/app/.cache/huggingface - - # Frontend - Production Configuration - frontend: - environment: - NEXT_PUBLIC_EXTERNAL_API_URL: ${NEXT_PUBLIC_EXTERNAL_API_URL} - NODE_ENV: production - restart: always - deploy: - resources: - limits: - cpus: '1' - memory: 1G - reservations: - cpus: '0.5' - memory: 512M - -volumes: - ml_models_cache: diff --git a/docker-compose.yml b/docker-compose.yml index f653c1c..4df318e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,10 +25,10 @@ services: context: ./zaban_backend dockerfile: Dockerfile container_name: zaban-backend - env_file: - - ./zaban_backend/.env environment: - DATABASE_URL: ${DATABASE_URL:-postgresql+psycopg://postgres:postgres@postgres:5432/zaban_backend_development} + - DATABASE_URL=${DATABASE_URL} + - SECRET_KEY=${SECRET_KEY:-} + - ALLOWED_HOSTS=${ALLOWED_HOSTS:-} ports: - "8000:8000" depends_on: @@ -45,11 +45,11 @@ services: build: context: ./frontend dockerfile: Dockerfile + args: + - NEXT_PUBLIC_EXTERNAL_API_URL=${NEXT_PUBLIC_EXTERNAL_API_URL:-http://localhost:8000} container_name: zaban-frontend - env_file: - - ./frontend/.env environment: - NEXT_PUBLIC_EXTERNAL_API_URL: ${NEXT_PUBLIC_EXTERNAL_API_URL:-http://localhost:8000} + - NEXT_PUBLIC_EXTERNAL_API_URL=${NEXT_PUBLIC_EXTERNAL_API_URL:-http://localhost:8000} ports: - "3000:3000" depends_on: diff --git a/frontend/.dockerignore b/frontend/.dockerignore index fc5dc4d..99b6eea 100644 --- a/frontend/.dockerignore +++ b/frontend/.dockerignore @@ -4,6 +4,8 @@ node_modules .gitignore README.md *.md +.env +.env* .env*.local .vscode .idea diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 4e59d7e..90f0518 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -18,6 +18,10 @@ COPY --from=deps /app/node_modules ./node_modules # Copy application code COPY . . +# Build arguments for NEXT_PUBLIC_* variables (must be available at build time) +ARG NEXT_PUBLIC_EXTERNAL_API_URL +ENV NEXT_PUBLIC_EXTERNAL_API_URL=${NEXT_PUBLIC_EXTERNAL_API_URL} + # Set build-time environment variables ENV NEXT_TELEMETRY_DISABLED=1 ENV NODE_ENV=production