Snippets

Frederik Banke docker-compose.yml

Created by Frederik Banke
version: "3.2"

services:
  ############## loadbalancer ################
  loadbalancer:
    image: 637345297332.dkr.ecr.eu-west-1.amazonaws.com/patch-loadbalancer:latest
    build: loadbalancer
    ports:
      - target: 8080
        published: 80
        protocol: tcp
        mode: host
      - target: 443
        published: 443
        protocol: tcp
        mode: host
   
    deploy:
      placement:
        constraints:
          - node.role == manager
    volumes:
          - /etc/letsencrypt:/etc/letsencrypt
          - /var/lib/letsencrypt:/var/lib/letsencrypt

  fileserver:
    image: 637345297332.dkr.ecr.eu-west-1.amazonaws.com/patch-fileserver:latest
    build: fileserver
    deploy:
      restart_policy:
        condition: none
      
    volumes:
      - /data/storage/patch_wp-core/_data:/var/wordpress/
      - /data/storage/patch_lund-fitness-data/_data/:/var/lund-fitness.dk

  ############ DB server ###################
  db:
    image: mariadb
    volumes:
      - db-data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=xxx
    deploy:
      placement:
        constraints:
          - node.role == manager

      resources:
        limits:
          memory: 300M

  backup-db:
    image: 637345297332.dkr.ecr.eu-west-1.amazonaws.com/patch-backup-sql:latest
    environment:
      - MYSQL_USER=root
      - MYSQL_PASSWORD=xxx
      - MYSQL_HOST=db
      - AWS_BUCKET_LOCATION=EU
      - AWS_ACCESS_KEY=xxx
      - AWS_SECRET_KEY=xxx
      - AWS_BUCKET=s3://sqlbackup.patch.dk/
    
    deploy:
      placement:
        constraints:
          - node.role != manager
      resources:
        limits:
          memory: 100M
   
  backup-files:
    image: thomaslomas/s3cmd-cron
    environment:
      - AWS_ACCESS_KEY=xxx
      - AWS_SECRET_KEY=xxx
      - AWS_BUCKET=s3://sqlbackup.patch.dk/wp-content/
      - AWS_BUCKET_LOCATION=EU
      - BACKUP_DIR=/data/
   
    volumes:
      - /data/storage/patch_datadriven-investment-data/_data:/backup/datadriven-investment:ro
      - /data/storage/patch_broderi-info-data/_data:/backup/broderi-info:ro
      - /data/storage/patch_nordic-safe-data/_data:/backup/nordic-safe:ro
      - /data/storage/patch_lund-fitness-data/_data:/backup/lund-fitness:ro
      - /data/storage/patch_super3booster-data/_data:/backup/super3booster:ro

    deploy:
      placement:
        constraints:
          - node.role != manager
      resources:
        limits:
          memory: 100M

  #################### WEBSITES ############
  http:
    image: 637345297332.dkr.ecr.eu-west-1.amazonaws.com/patch-httpd:latest
    build: httpd
   
    deploy:
      mode: global

      resources:
        limits:
          memory: 50M
     
    volumes:
      - /data/storage/patch_wp-core/_data:/var/www/nordic-safe.com/:ro
      - /data/storage/patch_wp-core/_data:/var/www/datadriven-investment.com/:ro
      - /data/storage/patch_wp-core/_data:/var/www/broderi-info.dk/:ro
      - /data/storage/patch_wp-core/_data:/var/www/lund-fitness.dk/:ro
      - /data/storage/patch_wp-core/_data:/var/www/super3booster.dk/:ro

      - /data/storage/patch_nordic-safe-data/_data:/var/www/nordic-safe.com/wp-content:ro
      - /data/storage/patch_datadriven-investment-data/_data:/var/www/datadriven-investment.com/wp-content:ro
      - /data/storage/patch_broderi-info-data/_data:/var/www/broderi-info.dk/wp-content:ro
      - /data/storage/patch_lund-fitness-data/_data:/var/www/lund-fitness.dk/wp-content:ro
      - /data/storage/patch_super3booster-data/_data:/var/www/super3booster.dk/wp-content:ro

  php:
    image: 637345297332.dkr.ecr.eu-west-1.amazonaws.com/patch-php-fpm:latest
    build: php-fpm

    environment:
      - PHP_VALIDATE_TIMESTAMPS=1
      - PHP_DISPLAY_ERRORS=0
      - PHP_ERROR_REPORTING=E_ALL

    deploy:
      mode: global
  
      resources:
        limits:
          memory: 150M

    volumes:
      - /data/storage/patch_wp-core/_data:/var/www/nordic-safe.com/:ro
      - /data/storage/patch_wp-core/_data:/var/www/datadriven-investment.com/:ro
      - /data/storage/patch_wp-core/_data:/var/www/broderi-info.dk/:ro
      - /data/storage/patch_wp-core/_data:/var/www/lund-fitness.dk/:ro
      - /data/storage/patch_wp-core/_data:/var/www/super3booster.dk/:ro

      - /data/storage/patch_nordic-safe-data/_data:/var/www/nordic-safe.com/wp-content
      - /data/storage/patch_datadriven-investment-data/_data:/var/www/datadriven-investment.com/wp-content # write allowed
      - /data/storage/patch_broderi-info-data/_data:/var/www/broderi-info.dk/wp-content # write allowed
      - /data/storage/patch_lund-fitness-data/_data:/var/www/lund-fitness.dk/wp-content # write allowed
      - /data/storage/patch_super3booster-data/_data:/var/www/super3booster.dk/wp-content # write allowed

  redis:
    image: redis:4.0.8-alpine

    deploy:
      placement:
        constraints:
          - node.role != manager

      resources:
        limits:
          memory: 100M
      
############## Data persisted on host #######
volumes:
  db-data: # database files
  influx:
    driver: local
  grafana:
    driver: local

Comments (0)