= Deploy 

== Create Yaml file

.docker-compose 
[source,yaml]
----
services:
  minio1: //<1>
    image: minio/minio:RELEASE.2020-04-10T03-34-42Z //<2>
    hostname: minio1 
    volumes:
      - minio1-data:/export //<3>
    ports:
      - "9001:9000" //<4>
    networks:
      - minio_distributed //<5>
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio1==true //<6>
    command: server http://minio{1...4}/export //<7>
    secrets: //<8>
      - secret_key 
      - access_key 
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"] //<9>
      interval: 30s
      timeout: 20s
      retries: 3

  minio2: //<10>
    image: minio/minio:RELEASE.2020-04-10T03-34-42Z
    hostname: minio2 //<10>
    volumes:
      - minio2-data:/export //<11>
    ports:
      - "9002:9000" //<12>
    networks:
      - minio_distributed //<5>
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio2==true //<13>
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio3:
    image: minio/minio:RELEASE.2020-04-10T03-34-42Z
    hostname: minio3
    volumes:
      - minio3-data:/export
    ports:
      - "9003:9000"
    networks:
      - minio_distributed //<5>
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio3==true
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  minio4:
    image: minio/minio:RELEASE.2020-04-10T03-34-42Z
    hostname: minio4
    volumes:
      - minio4-data:/export
    ports:
      - "9004:9000"
    networks:
      - minio_distributed //<5>
    deploy:
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      placement:
        constraints:
          - node.labels.minio4==true
    command: server http://minio{1...4}/export
    secrets:
      - secret_key
      - access_key
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
      interval: 30s
      timeout: 20s
      retries: 3

  web:
    image: nginx:1.17.9-alpine
    deploy:
      mode: replicated
      restart_policy:
        delay: 10s
        max_attempts: 10
        window: 60s
      replicas: 2
      placement:
        max_replicas_per_node: 1
        constraints:
          - node.labels.group==minio //<14>
    ports:
      - "8080:80"
      - "9443:443"
    volumes: //<15>
      - /PATH_to_FILE/minio.conf:/etc/nginx/conf.d/default.conf //<16>
      - /PATH_to_FILE/public.crt:/etc/nginx/public.crt //<17>
      - /PATH_to_FILE/private.key:/etc/nginx/private.key //<17>
    networks:
      - minio_distributed //<5>


volumes:
  minio1-data:

  minio2-data:

  minio3-data:

  minio4-data:


networks:
  minio_distributed: //<5>
    driver: overlay

secrets:
  secret_key:
    external: true
  access_key:
    external: true
                                               
----
<1> Service name
<2> Image name
<3> Volume to Use
<4> Expose port
<5> Network to Use
<6> Node Placement 
<7> Start server
<8> insert secrets
<9> health check command
<10> *NEW* Service name
<11> *NEW* Volume
<12> *NEW* Port
<13> *NEW* Label
<14> Node Placement (Proxy)
<15> Bind mount config files
<16> Nginx config file
<17> ssl keys
                                                              


