From 038570646c60e90543d343fb0e19a0f1f87ec5b0 Mon Sep 17 00:00:00 2001 From: masterdev Date: Tue, 16 Jun 2026 22:24:23 +0100 Subject: [PATCH] Fix Portainer file mounts --- README.md | 5 +++++ database/Dockerfile | 4 ++++ docker-compose.yml | 10 ++++------ mqtt/Dockerfile | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 database/Dockerfile create mode 100644 mqtt/Dockerfile diff --git a/README.md b/README.md index a9ee229..4de2758 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,11 @@ Expected exposed ports: PostgreSQL is intentionally not exposed by default in the Compose file. It is only reachable by the backend on the internal Docker network. +The stack builds small local images for `database` and `mqtt` so Portainer does +not need to bind-mount individual files like `database/init.sql` or +`mqtt/mosquitto.conf`. This avoids file-versus-directory mount errors in +Portainer Git stacks. + ### 4. Verify Open: diff --git a/database/Dockerfile b/database/Dockerfile new file mode 100644 index 0000000..f51eb3f --- /dev/null +++ b/database/Dockerfile @@ -0,0 +1,4 @@ +FROM postgres:16-alpine + +COPY init.sql /docker-entrypoint-initdb.d/01-init.sql +COPY seed.sql /docker-entrypoint-initdb.d/02-seed.sql diff --git a/docker-compose.yml b/docker-compose.yml index 2c32ec1..c07ee4c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,14 +1,13 @@ services: database: - image: postgres:16-alpine + build: + context: ./database environment: POSTGRES_DB: ${POSTGRES_DB:-plasttrack} POSTGRES_USER: ${POSTGRES_USER:-plasttrack} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-plasttrack} volumes: - postgres_data:/var/lib/postgresql/data - - ./database/init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro - - ./database/seed.sql:/docker-entrypoint-initdb.d/02-seed.sql:ro healthcheck: test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] interval: 5s @@ -16,12 +15,11 @@ services: retries: 20 mqtt: - image: eclipse-mosquitto:2 + build: + context: ./mqtt ports: - "1883:1883" - "9001:9001" - volumes: - - ./mqtt/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro healthcheck: test: ["CMD-SHELL", "mosquitto_sub -h localhost -p 1883 -t '$$SYS/broker/version' -C 1 -W 3 >/dev/null 2>&1"] interval: 10s diff --git a/mqtt/Dockerfile b/mqtt/Dockerfile new file mode 100644 index 0000000..4b0b4ee --- /dev/null +++ b/mqtt/Dockerfile @@ -0,0 +1,3 @@ +FROM eclipse-mosquitto:2 + +COPY mosquitto.conf /mosquitto/config/mosquitto.conf