Step 1 : Create .env at repo root runState/ where docker-compose.yml lies

.env

DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres_go?sslmode=disable"
JWT_SECRET=runState_Go
APP_ENV=dev
[email protected]
ADMIN_PASSWORD=runstate-admin-logging

MAILGUN_DOMAIN=sandboxf0ae1aa71b334d07abbef5327293e589.mailgun.org
MAILGUN_API_KEY=86bee704bceef52b9f8bdd5b80effaa1-f9517a64-c909c5b4
[email protected]

MONITORING_STREAM=betteruptime:websites-ticks
# ap-south-1 region id
MONITORING_REGION_NAME=ap-south-1
MONITORING_GROUP=monitoring-group 
MONITORING_CONSUMER=monitoring-consumer

STATUS_CHANGE_STREAM=betteruptime:website-status-change
STATUS_CHANGE_GROUP=status-change-group
STATUS_CHANGE_CONSUMER=status-change-consumer

NOTIFICATION_STREAM=betteruptime:website-status-notification
NOTIFICATION_GROUP=notification-group
NOTIFICATION_CONSUMER=notification-consumer

Step 2 : Add .env to .gitignore

Step 3 : Update docker-compose.yml to reference env vars (no secrets inline)

runState/docker-compose.yml

version: "3.9"
services:
  postgres:
    image: postgres:16
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres_go
    ports:
      - "5432:5432"
    volumes:
      - "pgdata:/var/lib/postgresql/data"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d postgres_go"]
      interval: 5s
      timeout: 3s
      retries: 30
      
  redis:
    image: redis:7
    ports:
      - "6379:6379"
    volumes:
      - redisdata:/data
    command: ["redis-server", "--appendonly", "yes"]
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 30
      
  api:
    build:
      context: .
      dockerfile: apps/api-go/Dockerfile
    image: runstate-api-go:local
    command: ["/server"]
    ports:
      - "8080:8080"
    environment:
      - DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres_go?sslmode=disable
      - REDIS_ADDR=redis:6379
      - APP_ENV=${APP_ENV}
      - ADMIN_EMAIL=${ADMIN_EMAIL}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  monitoring-pusher:
    image: runstate-api-go:local
    command: ["/monitoring-pusher"]
    environment:
      - DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres_go?sslmode=disable
      - REDIS_ADDR=redis:6379
      - MONITORING_STREAM=betteruptime:websites-ticks
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  worker-monitoring:
    image: runstate-api-go:local
    command: ["/worker-monitoring"]
    environment:
      - DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres_go?sslmode=disable
      - REDIS_ADDR=redis:6379
      - MONITORING_STREAM=betteruptime:websites-ticks
      - MONITORING_REGION_NAME=ap-south-1 
      - MONITORING_GROUP=monitoring-group 
      - MONITORING_CONSUMER=monitoring-consumer
      - STATUS_CHANGE_STREAM=betteruptime:website-status-change
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

  worker-status-change:
    image: runstate-api-go:local
    command: ["/worker-status-change"]
    environment:
      - DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres_go?sslmode=disable
      - REDIS_ADDR=redis:6379
      - STATUS_CHANGE_STREAM=betteruptime:website-status-change
      - STATUS_CHANGE_GROUP=status-change-group
      - STATUS_CHANGE_CONSUMER=status-change-consumer
      - NOTIFICATION_STREAM=betteruptime:website-status-notification
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
  
  worker-notification:
    image: runstate-api-go:local
    command: ["/worker-notification"]
    environment:
      - DATABASE_URL=postgres://postgres:postgres@postgres:5432/postgres_go?sslmode=disable
      - REDIS_ADDR=redis:6379
      - ADMIN_EMAIL=${ADMIN_EMAIL}
      - MAILGUN_DOMAIN=${MAILGUN_DOMAIN}
      - MAILGUN_API_KEY=${MAILGUN_API_KEY}
      - MAILGUN_SENDER=${MAILGUN_SENDER}
      - NOTIFICATION_STREAM=betteruptime:website-status-notification
      - NOTIFICATION_GROUP=notification-group
      - NOTIFICATION_CONSUMER=notification-consumer
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy

volumes:
  pgdata:
  redisdata:

Step 4. Push without secrets

brew install git-filter-repo
git filter-repo --path docker-compose.yml --invert-paths
git add docker-compose.yml .gitignore
git commit -m "Add docker-compose without secrets"
git push -u origin main --force

# fatal: Could not read from remote repository.
# Readd repo
git remote add origin <https://github.com/RitikaxG/runState.git>
git push -u origin main --force

Step 5 : Rebuild the image

docker compose up -d --build

image.png