docker-compose.dca.yml 6.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
# - + - + - + - + - + - + - + - + - + - + - + - + - +
#             NAIADES IoT Platform and services     #
# - + - + - + - + - + - + - + - + - + - + - + - + - +


# - + - + - + - + - + - + - + - + - + - + - + - + - +
#                     Notes                         #
# - + - + - + - + - + - + - + - + - + - + - + - + - +

# ToDoS for PROD
# ==============
# - include let's encrypt in nginx
# - platform's FQDM ?
# - all services requests must pass through nginx
# - change secrets


#
#  Authored by UDGA in the context of NAIADES E.U. PROJECT
#
#  Received contributions from
#  ---------------------------
#  - ?
#
#  inspired by https://smartsdk.github.io/smartsdk-recipes/
#
#  PRODUCTION ToDOs
#  ----------------
#  - include let's encrypt in nginx
#  - platform's FQDM ?
#  - all services requests must pass through nginx
#
#
#
#  DEPLOYMENT NOTES:
#  -----------------
#
#  About Docker Volumes:
#  ---------------------
#
#  A data volume is a specially-designated directory within one or more containers that bypasses the Union File System.
#  Data volumes provide several useful features for persistent or shared data:
#
#    - Volumes are initialized when a container is created.
#    If the container’s base image contains data at the specified mount point,
#    that existing data is copied into the new volume upon volume
#    initialization.
#    (Note that this does not apply when mounting a host
#    directory.)
#
#    - Data volumes can be shared and reused among containers.
#
#    - Changes to a data volume are made directly.
#
#    - Changes to a data volume will not be included when you update an image.
#    Data volumes persist even if the container itself is deleted.
#
#  Into Dockerfile you can specify only destination of volume inside container. e.g. /usr/src/app.
#  You may but -not necessary needed- specify mounting point (/opt) in host machine.
#  Using the CLI that is `docker run --volume=/opt:/usr/src/app my_image`
#  If you not specify --volume argument then mount point will be chosen automatically
#


version: "3.5"
services:

  # - + - + - + - + - + - + - + - + - + - + - + - + - +
  #                 Reverse-proxy                     #
  # - + - + - + - + - + - + - + - + - + - + - + - + - +

  # Reverse-proxy (entrypoint)
  nginx:
    image: nginx:latest
    container_name: nginx
    networks:
      default:
        ipv4_address: 172.18.2.250
    volumes:
      #- ${PWD}/nginx/error.log:/var/log/nginx/error.log:rw
      - ${PWD}/nginx/conf.d/:/etc/nginx/conf.d/
      - ${PWD}/nginx/cache/:/var/www/nginx/cache/
      - ${PWD}/nginx/logs/:/var/log/nginx/:rw
      - ${PWD}/nginx/nginx.conf:/etc/nginx/nginx.conf:rw
      - ${PWD}/nginx/htpasswd/:/etc/nginx/htpasswd/:rw
        #- /etc/letsencrypt/:/etc/letsencrypt/
    ports:
      - 80:80
      - 443:443
    depends_on:
      - dca-carouge-watering
      - dca-carouge-fountain
      - dca-carouge-weather
      - dca-carouge-weather-station
    command: [nginx-debug, '-g', 'daemon off;'] # THIS IS FOR DEBUG ONLY! DO NOT USE IN PROD!


  # - + - + - + - + - + - + - + - + - + - + - + - + - +
  #       DCA services                                #
  # - + - + - + - + - + - + - + - + - + - + - + - + - +

  dca-carouge-weather:
    build:
      context: ./dca-carouge-weather
      dockerfile: Dockerfile
    image: dca-carouge-weather:latest
    container_name: dca-carouge-weather
    environment:
      - LC_ALL=C.UTF-8
      - LANG=C.UTF-8
      - POST_DATA_PERIOD=900 #15mins
      - ORION_HOST=${ORION}
      - COLLECTION_DIR=/code/raw_data
    volumes:
      - ./dca-carouge-weather:/code:rw
    networks:
      default:
        ipv4_address: 172.18.2.15
    command: ./weather_00_collect_raw_weather_data_carouge.py # no sensors, only 3rd party data for the moment
#    healthcheck:
#      test: curl --fail -s http://dca-carouge-weather:${WMS_MODULE_PORT}/healthcheck || exit 1
#      start_period: 40s
#      interval: 15m00s
#      timeout: 10s
#      retries: 3

  dca-carouge-watering:
    build:
      context: ./dca-carouge-watering
      dockerfile: Dockerfile
    image: dca-carouge-watering:latest
    container_name: dca-carouge-watering
    environment:
      - LC_ALL=C.UTF-8
      - LANG=C.UTF-8
      - FLASK_ENV=development
      - FLASK_DEBUG=1
      - FLASK_RUN_PORT=80
      - COLLECTION_DIR=/code/raw_data
      - ORION_HOST=${ORION}
      - LORA_PLATFORM_SECRET_FILE=/run/secrets/lora_platform_auth_header
      - LORA_PLATFORM_URL=https://lora-ns.sig-ge.ch:443
    secrets:
      - lora_platform_auth_header
    expose:
      - 80
    volumes:
      - ./dca-carouge-watering:/code
    networks:
      default:
        ipv4_address: 172.18.2.14
    healthcheck:
      test: curl --fail -s http://dca-carouge-watering/healthcheck || exit 1
      start_period: 30s
      interval: 5m00s
      timeout: 10s
      retries: 3


  dca-carouge-fountain:
    build:
      context: ./dca-carouge-fountain
      dockerfile: Dockerfile
    image: dca-carouge-fountain:latest
    container_name: dca-carouge-fountain
    environment:
      - LC_ALL=C.UTF-8
      - LANG=C.UTF-8
      - FLASK_ENV=development
      - FLASK_DEBUG=1
      - FLASK_RUN_PORT=80
      - COLLECTION_DIR=/code/raw_data
      - ORION_HOST=${ORION}
      - LORA_PLATFORM_SECRET_FILE=/run/secrets/lora_platform_auth_header
      - LORA_PLATFORM_URL=https://eu.saas.orbiwise.com:443
    secrets:
      - lora_platform_auth_header
    expose:
      - 80
    volumes:
      - ./dca-carouge-fountain:/code
    networks:
      default:
        ipv4_address: 172.18.2.16
    healthcheck:
      test: curl --fail -s http://dca-carouge-fountain/healthcheck || exit 1
      start_period: 30s
      interval: 5m00s
      timeout: 10s
      retries: 3

  dca-carouge-weather-station:
    build:
      context: ./dca-carouge-weather-station
      dockerfile: Dockerfile
    image: dca-carouge-weather-station:latest
    container_name: dca-carouge-weather-station
    environment:
      - LC_ALL=C.UTF-8
      - LANG=C.UTF-8
      - FLASK_ENV=development
      - FLASK_DEBUG=1
      - FLASK_RUN_PORT=80
      - COLLECTION_DIR=/code/raw_data
      - ORION_HOST=${ORION}
    ports:
      - 21:21
    volumes:
      - ./dca-carouge-weather-station:/code
    networks:
      default:
        ipv4_address: 172.18.2.17
#    healthcheck:
#      test: curl --fail -s http://dca-carouge-fountain/healthcheck || exit 1
#      start_period: 30s
#      interval: 5m00s
#      timeout: 10s
#      retries: 3

# - + - + - + - + - + - + - + - + - + - + - + - + - +
#               Docker configs                      #
# - + - + - + - + - + - + - + - + - + - + - + - + - +

networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1450
      com.docker.network.bridge.name: naiades-network
    ipam:
      config:
        - subnet: 172.18.2.0/24

volumes:
  mysql-db: ~
  mongo-db: ~
  crate-storage: ~

secrets:
  db_password:
    file: secrets
  lora_platform_auth_header:
    file: secret_carouge_lora