
name: rd-srv-backend

services:
  # 主服务
  rd:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8800:8800"
    environment:
      spring.data.redis.host: redis
      spring.data.redis.port: 6379
      spring.datasource.url: jdbc:postgresql://db:5432/rdrev?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=Asia/Shanghai
      spring.datasource.username: postgres
      spring.datasource.password: a7d929f76d45d13a4337f2d16f5634bc17e5b8b2
      server.port: 8800
    depends_on:
      redis:
        condition: service_started
      db:
        condition: service_healthy
    networks:
      - rd-network

  # Postgresql
  db:
    image: postgres:14.12-alpine3.19
    environment:
      PGUSER: postgres
      POSTGRES_USER: postgres
      POSTGRES_DB: rdrev
      POSTGRES_PASSWORD: a7d929f76d45d13a4337f2d16f5634bc17e5b8b2
    volumes:
      - ./docker:/docker-entrypoint-initdb.d/
    networks:
      - rd-network
    healthcheck:
      test: [ "CMD-SHELL", "pg_isready", "-d", "db_prod"]
      interval: 10s
      timeout: 60s
      retries: 5
      start_period: 5s

  # Redis
  redis:
    image: redis
    networks:
      - rd-network

networks:
  rd-network:
    internal: false
