Docker compose file configuration

  docker, postgresql, redis

Developer context
On your project tech stack is based on Postgres, RabbitMQ and Redis. Your team regulary faces issue because of different versions of this tools. During last retrospective your team made decision resolve this problem with docker compose. There is approved list of environment variables:

DB_URL=postgresql://postgres:[email protected]:5432/nodejs-db
CACHE_URL=redis://localhost:6379
BUS_URL=amqp://user:[email protected]:5672

Task:
Create docker compose file what will include LTS version with Postgres, RabbitMQ and Redis. All services should run at the same network and be exposed on default port. Use environment variables for configuring docker containers.

my code:

version: "3.1"

services:
  postgres:
    image: postgres:13.5
    environment:
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: admin
      DB_URL: postgresql://postgres:[email protected]:5432/nodejs-db$
  redis:
    image: redis:6.0.16
    environment:
      CACHE_URL: redis://localhost:6379
    hostname: redis
    ports:
      - "6379:6379"
  rabbitmq:
    image: rabbitmq:3-management-alpine
    container_name: "rabbitmq"
    environment:
      BUS_URL: amqp://user:[email protected]:5672
      RABBITMQ_DEFAULT_USER: admin
      RABBITMQ_DEFAULT_PASS: password
    ports:
      - 5672:5672
      - 15672:15672

Source: Docker Questions

LEAVE A COMMENT