Ctrl K
ComunidadGuías…

compose.yaml

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
services:
  tollgate:
    container_name: tollgate
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
    env_file:
      - .env
    environment:
      PORT: 8080 # ポートマッピングと合わせて明示的に指定
      STORAGE_BACKEND: ${STORAGE_BACKEND:-${DB_BACKEND:-dynamodb}}
      RATE_LIMIT_BACKEND: ${RATE_LIMIT_BACKEND:-memory}
      DYNAMODB_ENDPOINT: ${DYNAMODB_ENDPOINT:-http://dynamodb:8000}
      REDIS_ADDR: ${REDIS_ADDR:-redis:6379}
      VALKEY_URL: ${VALKEY_URL:-redis://valkey:6379/0}
    depends_on:
      dynamodb:
        condition: service_started
        required: false
      dynamodb-init:
        condition: service_completed_successfully
        required: false
      redis:
        condition: service_started
        required: false
      valkey:
        condition: service_started
        required: false
      mock-server:
        condition: service_started
    healthcheck:
      test: [ "CMD-SHELL", "wget -q --spider http://localhost:8080/livez || exit 1" ]
      interval: 10s
      timeout: 5s
      retries: 5

  mock-server:
    container_name: mock-server
    build:
      context: .
      dockerfile: Dockerfile.mock
    ports:
      - "9000:8000"

  dynamodb:
    image: amazon/dynamodb-local:2.4.0
    command: "-jar DynamoDBLocal.jar -sharedDb -inMemory"
    ports:
      - "8000:8000"
    profiles:
      - dynamodb

  dynamodb-admin:
    image: aaronshaf/dynamodb-admin:latest
    ports:
      - "8001:8001"
    environment:
      DYNAMO_ENDPOINT: http://dynamodb:8000
      AWS_REGION: ap-northeast-1
    profiles:
      - dynamodb-admin
    depends_on:
      - dynamodb

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    command: redis-server --save "" --appendonly no # 永続化なし (レートリミット用途)
    profiles:
      - redis

  valkey:
    image: valkey/valkey:8-alpine
    ports:
      - "6379:6379"
    command: valkey-server --save "" --appendonly no
    profiles:
      - valkey

  dynamodb-init:
    image: amazon/aws-cli:latest
    environment:
      AWS_ACCESS_KEY_ID: dummy
      AWS_SECRET_ACCESS_KEY: dummy
      AWS_DEFAULT_REGION: ap-northeast-1
    entrypoint: [ "/bin/sh", "-c" ]
    command:
      - |
        aws dynamodb describe-table --table-name TollgateAPIKeys --endpoint-url http://dynamodb:8000 > /dev/null 2>&1 || \
        aws dynamodb create-table \
          --table-name TollgateAPIKeys \
          --endpoint-url http://dynamodb:8000 \
          --attribute-definitions \
            AttributeName=pk,AttributeType=S \
            AttributeName=tenant_id,AttributeType=S \
            AttributeName=service_id,AttributeType=S \
            AttributeName=item_type,AttributeType=S \
            AttributeName=created_at,AttributeType=S \
          --key-schema \
            AttributeName=pk,KeyType=HASH \
          --global-secondary-indexes \
            '[{"IndexName": "GSI_TenantKeys", "KeySchema": [{"AttributeName": "tenant_id", "KeyType": "HASH"}, {"AttributeName": "created_at", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"}}, {"IndexName": "GSI_ServiceKeys", "KeySchema": [{"AttributeName": "service_id", "KeyType": "HASH"}, {"AttributeName": "created_at", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"}}, {"IndexName": "GSI_AllKeys", "KeySchema": [{"AttributeName": "item_type", "KeyType": "HASH"}, {"AttributeName": "created_at", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"}}]' \
          --billing-mode PAY_PER_REQUEST
    profiles:
      - dynamodb
    depends_on:
      - dynamodb

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./deploy/monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    profiles:
      - monitor
    depends_on:
      - tollgate

  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    ports:
      - "3000:3000"
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
    volumes:
      - ./deploy/monitoring/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
      - ./deploy/monitoring/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
      - ./deploy/monitoring/grafana/dashboards:/var/lib/grafana/dashboards:ro
    profiles:
      - monitor
    depends_on:
      - prometheus