Fix Portainer file mounts

This commit is contained in:
masterdev
2026-06-16 22:24:23 +01:00
parent 4d6d9b53d3
commit 038570646c
4 changed files with 16 additions and 6 deletions

View File

@@ -149,6 +149,11 @@ Expected exposed ports:
PostgreSQL is intentionally not exposed by default in the Compose file. It is PostgreSQL is intentionally not exposed by default in the Compose file. It is
only reachable by the backend on the internal Docker network. 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 ### 4. Verify
Open: Open:

4
database/Dockerfile Normal file
View File

@@ -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

View File

@@ -1,14 +1,13 @@
services: services:
database: database:
image: postgres:16-alpine build:
context: ./database
environment: environment:
POSTGRES_DB: ${POSTGRES_DB:-plasttrack} POSTGRES_DB: ${POSTGRES_DB:-plasttrack}
POSTGRES_USER: ${POSTGRES_USER:-plasttrack} POSTGRES_USER: ${POSTGRES_USER:-plasttrack}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-plasttrack} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-plasttrack}
volumes: volumes:
- postgres_data:/var/lib/postgresql/data - 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: healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"] test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s interval: 5s
@@ -16,12 +15,11 @@ services:
retries: 20 retries: 20
mqtt: mqtt:
image: eclipse-mosquitto:2 build:
context: ./mqtt
ports: ports:
- "1883:1883" - "1883:1883"
- "9001:9001" - "9001:9001"
volumes:
- ./mqtt/mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
healthcheck: healthcheck:
test: ["CMD-SHELL", "mosquitto_sub -h localhost -p 1883 -t '$$SYS/broker/version' -C 1 -W 3 >/dev/null 2>&1"] test: ["CMD-SHELL", "mosquitto_sub -h localhost -p 1883 -t '$$SYS/broker/version' -C 1 -W 3 >/dev/null 2>&1"]
interval: 10s interval: 10s

3
mqtt/Dockerfile Normal file
View File

@@ -0,0 +1,3 @@
FROM eclipse-mosquitto:2
COPY mosquitto.conf /mosquitto/config/mosquitto.conf