version: '3.8'

services:
  postgres:
    image: postgres:15-alpine
    container_name: tudo_aqui_db
    environment:
      POSTGRES_DB: tudo_aqui_db
      POSTGRES_USER: tudo_aqui_admin
      POSTGRES_PASSWORD: senha_forte_2024
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./scripts/database:/docker-entrypoint-initdb.d
    ports:
      - "5432:5432"
    networks:
      - tudo_aqui_network

  redis:
    image: redis:7-alpine
    container_name: tudo_aqui_redis
    command: redis-server --requirepass redis_senha_2024
    volumes:
      - redis_data:/data
    ports:
      - "6379:6379"
    networks:
      - tudo_aqui_network

  app:
    build: .
    container_name: tudo_aqui_app
    environment:
      NODE_ENV: production
      DATABASE_HOST: postgres
      DATABASE_PORT: 5432
      DATABASE_NAME: tudo_aqui_db
      DATABASE_USER: tudo_aqui_admin
      DATABASE_PASSWORD: senha_forte_2024
      REDIS_HOST: redis
      REDIS_PORT: 6379
      REDIS_PASSWORD: redis_senha_2024
      JWT_SECRET: ${JWT_SECRET}
      AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
      AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
    ports:
      - "3000:3000"
    depends_on:
      - postgres
      - redis
    volumes:
      - ./uploads:/app/uploads
    networks:
      - tudo_aqui_network
    restart: unless-stopped

  nginx:
    image: nginx:alpine
    container_name: tudo_aqui_nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./ssl:/etc/nginx/ssl:ro
    depends_on:
      - app
    networks:
      - tudo_aqui_network
    restart: unless-stopped

networks:
  tudo_aqui_network:
    driver: bridge

volumes:
  postgres_data:
  redis_data:
