Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DilanLivera/6c824e0611bdf0bec28799bc507c0adc to your computer and use it in GitHub Desktop.
Save DilanLivera/6c824e0611bdf0bec28799bc507c0adc to your computer and use it in GitHub Desktop.
Sample Docker Compose file for reference

Sample Docker Compose file for reference

docker-compose.yml

version: '3'
services:
  mongo-db:
    image: mongo:latest
    ports:
      - "27017:27017"

  rabbitmq:
    image: rabbitmq:latest
    ports:
      - "5672:5672"
      - "15672:15672"
    environment:
      RABBITMQ_DEFAULT_USER: user
      RABBITMQ_DEFAULT_PASS: password

  web-service-1:
    build:
      context: ./service1 # Path to the service 1 folder containing Dockerfile
    depends_on:
      - mongo-db
      - rabbitmq
    environment:
      MONGO_HOST: mongo-db
      RABBITMQ_HOST: rabbitmq
    ports:
      - "8001:8001"

  web-service-2:
    build:
      context: ./service2 # Path to the service 2 folder containing Dockerfile
    depends_on:
      - mongo-db
      - rabbitmq
    environment:
      MONGO_HOST: mongo-db
      RABBITMQ_HOST: rabbitmq
    ports:
      - "8002:8002"

How to use the environment variables from an appsetting file of a .NET application

{
  "ConnectionStrings": {
    "MongoDb": "mongodb://[MONGO_HOST]:27017",
    "RabbitMq": "amqp://[RABBITMQ_HOST]"
  },
  
  // Other settings
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment