Last active
September 5, 2026 05:19
-
-
Save ankurk91/aeda6722ca7b2205c4aca28b2429a0ab to your computer and use it in GitHub Desktop.
My docker compose for local development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # --------------------------------------------------------------------------- | |
| # Local development stack. NOT for production / shared hosts. | |
| # --------------------------------------------------------------------------- | |
| BIND_ADDR=127.0.0.1 | |
| # --- PostgreSQL ------------------------------------------------------------ | |
| FORWARD_PGSQL_PORT=5432 | |
| PGSQL_USER=postgres | |
| PGSQL_PASSWORD=postgres | |
| PGSQL_DB=app | |
| # --- MySQL ----------------------------------------------------------------- | |
| FORWARD_MYSQL_PORT=3306 | |
| MYSQL_ROOT_PASSWORD=secret | |
| MYSQL_DATABASE=app | |
| MYSQL_USER=app | |
| MYSQL_PASSWORD=secret | |
| # --- Valkey ---------------------------------------------------------------- | |
| FORWARD_VALKEY_PORT=6379 | |
| # --- Mailpit --------------------------------------------------------------- | |
| FORWARD_MAILPIT_PORT=1025 | |
| FORWARD_MAILPIT_UI_PORT=8025 | |
| # --- S3 object storage ----------------------------------------------------- | |
| FORWARD_S3_PORT=9000 | |
| FORWARD_S3_CONSOLE_PORT=9001 | |
| S3_ACCESS_KEY=rustfsadmin | |
| S3_SECRET_KEY=rustfsadmin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: dev-stack | |
| x-logging: &logging | |
| driver: json-file | |
| options: | |
| max-size: "10m" | |
| max-file: "3" | |
| x-healthcheck: &healthcheck | |
| interval: 10s | |
| timeout: 5s | |
| retries: 5 | |
| start_period: 30s | |
| x-service: &service | |
| restart: unless-stopped | |
| logging: *logging | |
| networks: | |
| - docker-net | |
| services: | |
| postgres18: | |
| <<: *service | |
| image: 'public.ecr.aws/docker/library/postgres:18-alpine' | |
| container_name: postgres-18 | |
| ports: | |
| - "${BIND_ADDR:-127.0.0.1}:${FORWARD_PGSQL_PORT:-5432}:5432" | |
| volumes: | |
| - pg-18-data:/var/lib/postgresql | |
| # Default /dev/shm is 64MB, which parallel query workers can exhaust. | |
| shm_size: 256mb | |
| environment: | |
| POSTGRES_USER: '${PGSQL_USER:-postgres}' | |
| POSTGRES_PASSWORD: '${PGSQL_PASSWORD:-postgres}' | |
| POSTGRES_DB: '${PGSQL_DB:-app}' | |
| healthcheck: | |
| <<: *healthcheck | |
| # -h forces a TCP check, so this stays red while the entrypoint's | |
| # temporary init server is up and only the local socket is listening. | |
| test: [ "CMD-SHELL", "pg_isready -h 127.0.0.1 -U ${PGSQL_USER:-postgres} -d ${PGSQL_DB:-app}" ] | |
| deploy: | |
| resources: | |
| limits: | |
| cpus: '2' | |
| memory: 1g | |
| valkey9: | |
| <<: *service | |
| image: 'valkey/valkey:9-alpine' | |
| container_name: valkey-9 | |
| command: | |
| - valkey-server | |
| - --bind | |
| - 0.0.0.0 | |
| - --appendonly | |
| - "yes" | |
| # Keep the dataset under the container memory limit so Valkey applies its | |
| # own policy instead of being OOM-killed by the kernel. noeviction is the | |
| # safe choice when Valkey backs a queue; use allkeys-lru for a pure cache. | |
| - --maxmemory | |
| - "384mb" | |
| - --maxmemory-policy | |
| - "noeviction" | |
| ports: | |
| - "${BIND_ADDR:-127.0.0.1}:${FORWARD_VALKEY_PORT:-6379}:6379" | |
| healthcheck: | |
| <<: *healthcheck | |
| test: [ "CMD", "valkey-cli", "ping" ] | |
| volumes: | |
| - valkey-9-data:/data | |
| deploy: | |
| resources: | |
| limits: | |
| cpus: '1' | |
| memory: 512m | |
| mysql8: | |
| <<: *service | |
| image: 'public.ecr.aws/docker/library/mysql:8.4' | |
| container_name: mysql-8 | |
| command: | |
| # Sized to sit under the memory limit below. | |
| - '--innodb-buffer-pool-size=256M' | |
| ports: | |
| - "${BIND_ADDR:-127.0.0.1}:${FORWARD_MYSQL_PORT:-3306}:3306" | |
| healthcheck: | |
| <<: *healthcheck | |
| # -h 127.0.0.1 for the same init-race reason as postgres above. | |
| test: [ "CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u root -p\"$$MYSQL_ROOT_PASSWORD\" --silent" ] | |
| volumes: | |
| - mysql-8-data:/var/lib/mysql | |
| # - ./mysql:/etc/mysql/conf.d | |
| environment: | |
| MYSQL_ROOT_PASSWORD: '${MYSQL_ROOT_PASSWORD:-secret}' | |
| MYSQL_DATABASE: '${MYSQL_DATABASE:-app}' | |
| MYSQL_USER: '${MYSQL_USER:-app}' | |
| MYSQL_PASSWORD: '${MYSQL_PASSWORD:-secret}' | |
| deploy: | |
| resources: | |
| limits: | |
| cpus: '2' | |
| memory: 1g | |
| mailpit: | |
| <<: *service | |
| image: 'axllent/mailpit:latest' | |
| container_name: mailpit | |
| ports: | |
| - '${BIND_ADDR:-127.0.0.1}:${FORWARD_MAILPIT_PORT:-1025}:1025' | |
| - '${BIND_ADDR:-127.0.0.1}:${FORWARD_MAILPIT_UI_PORT:-8025}:8025' | |
| environment: | |
| MP_DATABASE: /data/mailpit.db | |
| MP_MAX_MESSAGES: '500' | |
| volumes: | |
| - mailpit-data:/data | |
| healthcheck: | |
| <<: *healthcheck | |
| test: [ "CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8025/readyz" ] | |
| deploy: | |
| resources: | |
| limits: | |
| cpus: '1' | |
| memory: 256m | |
| s3: | |
| <<: *service | |
| image: 'rustfs/rustfs:rc' | |
| container_name: rustfs | |
| ports: | |
| - '${BIND_ADDR:-127.0.0.1}:${FORWARD_S3_PORT:-9000}:9000' | |
| - '${BIND_ADDR:-127.0.0.1}:${FORWARD_S3_CONSOLE_PORT:-9001}:9001' | |
| environment: | |
| RUSTFS_VOLUMES: /data | |
| RUSTFS_ADDRESS: '0.0.0.0:9000' | |
| RUSTFS_CONSOLE_ADDRESS: '0.0.0.0:9001' | |
| RUSTFS_CONSOLE_ENABLE: 'true' | |
| RUSTFS_ACCESS_KEY: '${S3_ACCESS_KEY:-rustfsadmin}' | |
| RUSTFS_SECRET_KEY: '${S3_SECRET_KEY:-rustfsadmin}' | |
| RUSTFS_OBS_LOGGER_LEVEL: warn | |
| volumes: | |
| - rustfs-data:/data | |
| healthcheck: | |
| <<: *healthcheck | |
| test: [ "CMD", "curl", "-fsS", "http://127.0.0.1:9000/health" ] | |
| deploy: | |
| resources: | |
| limits: | |
| cpus: '2' | |
| memory: 1g | |
| volumes: | |
| mysql-8-data: | |
| pg-18-data: | |
| valkey-9-data: | |
| mailpit-data: | |
| rustfs-data: | |
| networks: | |
| docker-net: | |
| driver: bridge |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reserved comment