pact-foundation / pact-stub-server

Standalone pact stub server
MIT License
75 stars 19 forks source link

Sample Docker Compose #57

Open neillfontes-klar opened 1 year ago

neillfontes-klar commented 1 year ago

If anyone needs a docker-compose.yaml for local testing, the one below can be leveraged:

version: "3"

services:

  postgres:
    image: postgres
    healthcheck:
      test: pg_isready -U postgres
      interval: 5s
      timeout: 3s
      retries: 3
      start_period: 1s
    hostname: postgres
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: postgres
    networks:
      - net

  pact_broker:
    image: pactfoundation/pact-broker
    ports:
      - "8000:9292"
    hostname: broker
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: netstat -tuln | grep -q :9292
      interval: 5s
      timeout: 3s
      retries: 3
      start_period: 1s
    links:
      - postgres
    environment:
      PACT_BROKER_BASIC_AUTH_USERNAME: pact_workshop
      PACT_BROKER_BASIC_AUTH_PASSWORD: pact_workshop
      PACT_BROKER_DATABASE_USERNAME: postgres
      PACT_BROKER_DATABASE_PASSWORD: password
      PACT_BROKER_DATABASE_HOST: postgres
      PACT_BROKER_DATABASE_NAME: postgres
    networks:
      - net

  pact_stub:
    image: pactfoundation/pact-stub-server
    ports:
      - "8080:8080"
    hostname: stub
    depends_on:
      pact_broker:
        condition: service_healthy
    command:
      --port 8080
      --broker-url http://host.docker.internal:8000
      --user pact_workshop:pact_workshop
      --loglevel debug
    networks:
      - net

networks:
  net:
    driver: bridge

Not necessarily a question/issue but it might be useful for others.