Skip to content

Run

volumes:
  db:
  data_es:


services:
  db:
    image: postgres:14.3
    shm_size: 512m
    command: # full form
      - "postgres"
      - "-c"
      - "max_connections=1000"
      - "-c"
      - "shared_buffers=256MB"
    volumes:
      - db:/var/lib/postgresql/data
      - ./postgres/init:/docker-entrypoint-initdb.d
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASS=postgres
      - PGUSER=postgres
      - POSTGRES_HOST_AUTH_METHOD=trust
    ports:
      - "5432:5432"
    healthcheck:
      test: [ "CMD-SHELL", "su - postgres -c 'pg_isready -h db -U postgres'" ]
      interval: 3s
      timeout: 10s
      retries: 5

  redis:
    image: redis:4.0.11-alpine3.8
    ports:
      - "6379:6379"
    healthcheck:
      test: [ "CMD", "redis-cli", "ping" ]
      interval: 10s
      timeout: 10s
      retries: 5

  # Step 2 of the ES 8 → 9 migration: official Elastic image reading the same
  # data volume that Bitnami ES 8.18 wrote. Two compatibility issues are
  # handled here, mirroring the prod k8s manifest:
  #   1. UID: Bitnami runs as 1001, official ES 9 runs as 1000. The init
  #      container chowns the volume once before ES starts.
  #   2. Data path: Bitnami stores at /bitnami/elasticsearch/data; we keep
  #      that path via the path.data env so ES 9 reads existing indexes
  #      without a move/copy.
  # The analysis-phonetic plugin (auto-installed by Bitnami via env) is
  # installed by the official image via the command wrapper at boot.
  elasticsearch-init:
    image: busybox:1.36
    user: "0:0"
    command: ["sh", "-c", "chown -R 1000:0 /data && chmod -R g+rwX /data && echo 'data_es chowned to 1000:0 for official ES 9'"]
    volumes:
      - data_es:/data

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:9.0.1
    depends_on:
      elasticsearch-init:
        condition: service_completed_successfully
    command: >
      bash -c "
        bin/elasticsearch-plugin install analysis-phonetic --batch --silent 2>/dev/null || true &&
        exec /usr/local/bin/docker-entrypoint.sh eswrapper
      "
    environment:
      - "ES_JAVA_OPTS=-Xms2g -Xmx2g"
      - "xpack.security.enabled=false"
      - "xpack.security.http.ssl.enabled=false"
      - "discovery.type=single-node"
      - "path.data=/bitnami/elasticsearch/data"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - data_es:/bitnami/elasticsearch/data
    ports:
      - "9200:9200"
    healthcheck:
      test: [ "CMD-SHELL", "curl -f http://localhost:9200/_cluster/health || exit 1" ]
      interval: 10s
      timeout: 10s
      retries: 3