From ab940917e3559fd0415284b1bcdc43ac59c34c46 Mon Sep 17 00:00:00 2001 From: PPawlowski Date: Mon, 14 Oct 2024 10:21:11 +0200 Subject: [PATCH 1/3] Introduce quick-start compose file --- docker-compose-quick-start.yml | 208 +++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 docker-compose-quick-start.yml diff --git a/docker-compose-quick-start.yml b/docker-compose-quick-start.yml new file mode 100644 index 0000000..8cacc5d --- /dev/null +++ b/docker-compose-quick-start.yml @@ -0,0 +1,208 @@ +name: flowfuse + +configs: + flowfuse: + content: | + port: 3000 + host: 0.0.0.0 + domain: ${DOMAIN:?error} + base_url: http://forge.${DOMAIN:?error} + api_url: http://forge:3000 + db: + logging: false + type: postgres + host: postgres + user: forge + password: secret + driver: + type: docker + options: + socket: /tmp/docker.sock + broker: + url: mqtt://flowforge-broker:1883 + public_url: ws://mqtt.${DOMAIN:?error} + fileStore: + url: http://file-server:3001 + flowfuse_broker: + content: | + per_listener_settings false + allow_anonymous false + listener 1883 0.0.0.0 + listener 1884 0.0.0.0 + protocol websockets + auth_plugin /mosquitto/go-auth.so + auth_opt_backends http + auth_opt_hasher bcrypt + auth_opt_cache true + auth_opt_auth_cache_seconds 30 + auth_opt_acl_cache_seconds 90 + auth_opt_auth_jitter_second 3 + auth_opt_acl_jitter_seconds 5 + auth_opt_http_host forge + auth_opt_http_port 3000 + auth_opt_http_getuser_uri /api/comms/auth/client + auth_opt_http_aclcheck_uri /api/comms/auth/acl + flowfuse_storage: + content: | + port: 3001 + host: 0.0.0.0 + base_url: http://forge:3000 + driver: + type: localfs + quota: 104857600 + options: + root: var/root + context: + type: sequelize + quota: 1048576 + options: + type: postgres + host: postgres + database: ff-context + username: forge + password: secret + nginx: + content: | + client_max_body_size 5m; + postgres_db_setup: + content: | + #!/bin/sh + set -e + psql -v ON_ERROR_STOP=1 -U root <<-ESQL + CREATE USER forge WITH PASSWORD 'secret'; + CREATE DATABASE flowforge; + GRANT ALL PRIVILEGES ON DATABASE flowforge TO forge; + ESQL + postgres_context_setup: + content: | + #!/bin/sh + set -e + psql -v ON_ERROR_STOP=1 -U root <<-ESQL + SELECT 'CREATE DATABASE "ff-context"' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'ff-context')\gexec + GRANT ALL PRIVILEGES ON DATABASE "ff-context" TO "forge"; + ESQL + +services: + nginx: + image: nginxproxy/nginx-proxy:1.6.0 + networks: + - flowforge + restart: always + volumes: + - "/var/run/docker.sock:/tmp/docker.sock:ro" + # - "./nginx/vhost.d:/etc/nginx/vhost.d" + # - "./nginx/html:/usr/share/nginx/html" + # - "./nginx/my-proxy.conf:/etc/nginx/conf.d/my_proxy.conf" + # - "./certs:/etc/nginx/certs" + configs: + - source: nginx + target: /etc/nginx/conf.d/my_proxy.conf + ports: + - "80:80" + # - "443:443" + # environment: + # - "HTTPS_METHOD=redirect" + # acme: + # image: nginxproxy/acme-companion:2.4.0 + # restart: always + # volumes: + # - "/var/run/docker.sock:/var/run/docker.sock:ro" + # - "./acme:/etc/acme.sh" + # volumes_from: + # - nginx:rw + # environment: + # - "DEFAULT_EMAIL=mail@example.com" + # depends_on: + # - "nginx" + postgres: + image: postgres:14 + networks: + - flowforge + restart: always + environment: + POSTGRES_PASSWORD: secret + POSTGRES_USER: root + configs: + - source: postgres_db_setup + target: /docker-entrypoint-initdb.d/01-setup-db.sh + - source: postgres_context_setup + target: /docker-entrypoint-initdb.d/02-setup-context-db.sh + volumes: + - db:/var/lib/postgresql/data + # - "./setup-db.sh:/docker-entrypoint-initdb.d/01-setup-db.sh" + # - "./setup-context-db.sh:/docker-entrypoint-initdb.d/02-setup-context-db.sh" + flowforge-broker: + image: "iegomez/mosquitto-go-auth" + networks: + - flowforge + restart: always + ulimits: + nofile: 2048 + environment: + - "VIRTUAL_HOST=mqtt.${DOMAIN:?error}" + - "VIRTUAL_PORT=1884" + - "LETSENCRYPT_HOST=mqtt.${DOMAIN:?error}" + configs: + - source: flowfuse_broker + target: /etc/mosquitto/mosquitto.conf + # volumes: + # - "./broker/mosquitto.conf:/etc/mosquitto/mosquitto.conf" + forge: + # build: + # context: "./flowforge-docker" + image: "flowfuse/forge-docker" + networks: + - flowforge + restart: always + environment: + - "VIRTUAL_HOST=forge.${DOMAIN:?error}" + - "LETSENCRYPT_HOST=forge.${DOMAIN:?error}" + configs: + - source: flowfuse + target: /usr/src/forge/etc/flowforge.yml + volumes: + - "/var/run/docker.sock:/tmp/docker.sock" + # - "./etc/flowforge.yml:/usr/src/forge/etc/flowforge.yml" + - flowfuse-persistent-storage:/opt/persistent-storage + depends_on: + - "postgres" + - "nginx" + - "flowforge-broker" + + file-server: + # build: + # context: "./file-server" + image: "flowfuse/file-server" + networks: + - flowforge + restart: always + configs: + - source: flowfuse_storage + target: /usr/src/flowforge-file-server/etc/flowforge-storage.yml + volumes: + # - "./etc/flowforge-storage.yml:/usr/src/flowforge-file-server/etc/flowforge-storage.yml" + - fileStorage:/usr/src/flowforge-file-server/var/root + depends_on: + - "forge" + + # npm: + # image: "verdaccio/verdaccio:5" + # networks: + # - flowforge + # restart: always + # environment: + # - "VIRTUAL_HOST=npm.example.com" + # - "VIRTUAL_PORT=4873" + # volumes: + # - "./npm/conf:/verdaccio/conf" + # - "./npm/storage:/verdaccio/storage" + # depends_on: + # - nginx + +networks: + flowforge: + +volumes: + flowfuse-persistent-storage: + db: + fileStorage: \ No newline at end of file From 29d9dabbd284ea4d8e36220dd924c25ccb9d3804 Mon Sep 17 00:00:00 2001 From: PPawlowski Date: Mon, 14 Oct 2024 10:25:12 +0200 Subject: [PATCH 2/3] Cleanup --- docker-compose-quick-start.yml | 43 ---------------------------------- 1 file changed, 43 deletions(-) diff --git a/docker-compose-quick-start.yml b/docker-compose-quick-start.yml index 8cacc5d..d6a3678 100644 --- a/docker-compose-quick-start.yml +++ b/docker-compose-quick-start.yml @@ -90,30 +90,11 @@ services: restart: always volumes: - "/var/run/docker.sock:/tmp/docker.sock:ro" - # - "./nginx/vhost.d:/etc/nginx/vhost.d" - # - "./nginx/html:/usr/share/nginx/html" - # - "./nginx/my-proxy.conf:/etc/nginx/conf.d/my_proxy.conf" - # - "./certs:/etc/nginx/certs" configs: - source: nginx target: /etc/nginx/conf.d/my_proxy.conf ports: - "80:80" - # - "443:443" - # environment: - # - "HTTPS_METHOD=redirect" - # acme: - # image: nginxproxy/acme-companion:2.4.0 - # restart: always - # volumes: - # - "/var/run/docker.sock:/var/run/docker.sock:ro" - # - "./acme:/etc/acme.sh" - # volumes_from: - # - nginx:rw - # environment: - # - "DEFAULT_EMAIL=mail@example.com" - # depends_on: - # - "nginx" postgres: image: postgres:14 networks: @@ -129,8 +110,6 @@ services: target: /docker-entrypoint-initdb.d/02-setup-context-db.sh volumes: - db:/var/lib/postgresql/data - # - "./setup-db.sh:/docker-entrypoint-initdb.d/01-setup-db.sh" - # - "./setup-context-db.sh:/docker-entrypoint-initdb.d/02-setup-context-db.sh" flowforge-broker: image: "iegomez/mosquitto-go-auth" networks: @@ -145,11 +124,7 @@ services: configs: - source: flowfuse_broker target: /etc/mosquitto/mosquitto.conf - # volumes: - # - "./broker/mosquitto.conf:/etc/mosquitto/mosquitto.conf" forge: - # build: - # context: "./flowforge-docker" image: "flowfuse/forge-docker" networks: - flowforge @@ -162,7 +137,6 @@ services: target: /usr/src/forge/etc/flowforge.yml volumes: - "/var/run/docker.sock:/tmp/docker.sock" - # - "./etc/flowforge.yml:/usr/src/forge/etc/flowforge.yml" - flowfuse-persistent-storage:/opt/persistent-storage depends_on: - "postgres" @@ -170,8 +144,6 @@ services: - "flowforge-broker" file-server: - # build: - # context: "./file-server" image: "flowfuse/file-server" networks: - flowforge @@ -180,25 +152,10 @@ services: - source: flowfuse_storage target: /usr/src/flowforge-file-server/etc/flowforge-storage.yml volumes: - # - "./etc/flowforge-storage.yml:/usr/src/flowforge-file-server/etc/flowforge-storage.yml" - fileStorage:/usr/src/flowforge-file-server/var/root depends_on: - "forge" - # npm: - # image: "verdaccio/verdaccio:5" - # networks: - # - flowforge - # restart: always - # environment: - # - "VIRTUAL_HOST=npm.example.com" - # - "VIRTUAL_PORT=4873" - # volumes: - # - "./npm/conf:/verdaccio/conf" - # - "./npm/storage:/verdaccio/storage" - # depends_on: - # - nginx - networks: flowforge: From 959e934093bc81773f9755dc8e8af37a0a024c4e Mon Sep 17 00:00:00 2001 From: PPawlowski Date: Mon, 14 Oct 2024 20:23:18 +0200 Subject: [PATCH 3/3] Remove "flowforge" references where possible --- docker-compose-quick-start.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docker-compose-quick-start.yml b/docker-compose-quick-start.yml index d6a3678..39eb3f9 100644 --- a/docker-compose-quick-start.yml +++ b/docker-compose-quick-start.yml @@ -12,6 +12,7 @@ configs: logging: false type: postgres host: postgres + database: flowfuse user: forge password: secret driver: @@ -19,7 +20,7 @@ configs: options: socket: /tmp/docker.sock broker: - url: mqtt://flowforge-broker:1883 + url: mqtt://broker:1883 public_url: ws://mqtt.${DOMAIN:?error} fileStore: url: http://file-server:3001 @@ -70,8 +71,8 @@ configs: set -e psql -v ON_ERROR_STOP=1 -U root <<-ESQL CREATE USER forge WITH PASSWORD 'secret'; - CREATE DATABASE flowforge; - GRANT ALL PRIVILEGES ON DATABASE flowforge TO forge; + CREATE DATABASE flowfuse; + GRANT ALL PRIVILEGES ON DATABASE flowfuse TO forge; ESQL postgres_context_setup: content: | @@ -110,7 +111,7 @@ services: target: /docker-entrypoint-initdb.d/02-setup-context-db.sh volumes: - db:/var/lib/postgresql/data - flowforge-broker: + broker: image: "iegomez/mosquitto-go-auth" networks: - flowforge @@ -141,7 +142,7 @@ services: depends_on: - "postgres" - "nginx" - - "flowforge-broker" + - "broker" file-server: image: "flowfuse/file-server"