johnrees/fablabs

View on GitHub
docker-compose.yml

Summary

Maintainability
Test Coverage
version: '2.2'

services:
  redis:
    image: redis:6
    hostname: redis
    restart: always
    command: redis-server /usr/local/etc/redis/redis.conf
    volumes:
      - ./scripts/redis.conf:/usr/local/etc/redis/redis.conf

  db:
    image: postgres:10.23-bullseye
    restart: always
    hostname: db1
    # persist the database between containers by storing it in a volume
    volumes:
      - fablabs-postgres:/var/lib/postgresql/data
      #- ./dump:/dump
    #environment:
      # NOTE: Postgres 9.5 stopped allowing connections without passwords.
      # Enable this if needed.
      #- POSTGRES_HOST_AUTH_METHOD=trust

  app:
    env_file: .env
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/fablabs
      - /fablabs/tmp
    depends_on:
      - db
      - redis
    container_name: app
    environment:
      - SSL_POLICY=AWS-TLS-1-2-2017-01
      - VIRTUAL_HOST=${VIRTUAL_HOST}
      - VIRTUAL_PORT=${VIRTUAL_PORT}
      - LETSENCRYPT_HOST=${LETSENCRYPT_HOST}
      - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
    ports:
      - "3000:3000"
    restart: always
    logging:
      driver: "json-file"
      options:
        max-size: "100m"

  worker:
    env_file: .env
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - /fablabs/tmp
    volumes_from:
      - app
    command: bash -c "sleep 3 && bundle exec sidekiq -e $RAILS_ENV"
    restart: always
    depends_on:
      - app
      - db

  nginx:
    restart: always
    image: nginx
    container_name: nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/etc/nginx/conf.d"
      - "/etc/nginx/vhost.d"
      - "/usr/share/nginx/html"
      - "./volumes/proxy/certs:/etc/nginx/certs:ro"

  nginx-gen:
    restart: always
    image: jwilder/docker-gen
    container_name: nginx-gen
    volumes:
      - "/var/run/docker.sock:/tmp/docker.sock:ro"
      - "./volumes/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
    volumes_from:
      - nginx
    environment:
      - SSL_POLICY=AWS-TLS-1-2-2017-01
    entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

  letsencrypt-nginx-proxy-companion:
    restart: always
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-nginx-proxy-companion
    volumes_from:
      - nginx
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./volumes/proxy/certs:/etc/nginx/certs:rw"
    environment:
      # unset this for real certs
      #- ACME_CA_URI=https://acme-staging.api.letsencrypt.org/directory
      - NGINX_DOCKER_GEN_CONTAINER=nginx-gen
      - NGINX_PROXY_CONTAINER=nginx

volumes:
  fablabs-postgres: