x-default: &default restart: unless-stopped volumes: - &localtime /etc/localtime:/etc/localtime:ro - &timezone /etc/timezone:/etc/timezone:ro logging: driver: json-file options: max-size: 100m x-mongo: &mongo <<: *default image: mongo:${MONGO_VERSION:-8.0.13} environment: MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME:-root} MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD:-password} MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE:-admin} command: - mongod - --replSet - ${MONGO_REPLICA_SET_NAME:-rs0} - --keyFile - /secrets/rs0.key volumes: - *localtime - *timezone - ./secrets/rs0.key:/secrets/rs0.key entrypoint: - bash - -c - | chmod 400 /secrets/rs0.key chown 999:999 /secrets/rs0.key exec docker-entrypoint.sh $$@ deploy: resources: limits: cpus: '0.50' memory: 1G reservations: cpus: '0.25' memory: 256M services: mongo1: <<: *mongo ports: - "${MONGO_PORT_OVERRIDE_1:-27017}:27017" mongo2: <<: *mongo ports: - "${MONGO_PORT_OVERRIDE_2:-27018}:27017" mongo3: <<: *mongo ports: - "${MONGO_PORT_OVERRIDE_3:-27019}:27017"