Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# docker-compose.yml
# Vollständiger Stack für Cap Web, Datenbank und S3-kompatiblen Speicher

version: '3.8'

services:
# Der Hauptdienst: Die Cap Web-Anwendung
cap-web:
# Baut das Image direkt aus dem Quellcode in diesem Repository.
# Dies ist entscheidend für ARM64-Architekturen wie Raspberry Pi oder Apple Silicon.
build: .
restart: always
ports:
# Mappt den internen Port 3000 auf den externen Port 3000 des Servers.
# Ändern Sie "3000:3000", falls der Port 3000 auf Ihrem Host bereits belegt ist.
- "3000:3000"
environment:
# Verweist auf die .env-Datei für die Konfiguration.
# Alternativ können diese Variablen direkt in Ihrer Deployment-Plattform gesetzt werden.
- DATABASE_URL=${DATABASE_URL}
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
- NEXTAUTH_URL=${NEXTAUTH_URL}
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
- S3_SECRET_KEY=${S3_SECRET_KEY}
- S3_ENDPOINT=${S3_ENDPOINT}
- S3_REGION=${S3_REGION}
- S3_BUCKET=${S3_BUCKET}
# Optional für E-Mail-Login-Links (siehe Doku)
# - RESEND_API_KEY=${RESEND_API_KEY}
# - RESEND_FROM_DOMAIN=${RESEND_FROM_DOMAIN}
depends_on:
- db
- minio
networks:
- cap-network
Comment on lines +31 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add health checks to ensure service readiness before startup.

depends_on alone does not guarantee service readiness—MySQL and MinIO may still be initializing when cap-web starts. Add health checks to prevent startup race conditions.

For MySQL (lines 38–50), add:

  db:
    image: mysql:8.0
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - db-data:/var/lib/mysql
+   healthcheck:
+     test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
+     interval: 10s
+     timeout: 5s
+     retries: 5
    networks:
      - cap-network

For MinIO (lines 53–69), add:

  minio:
    image: minio/minio:2024.11.07
    restart: always
    ports:
      - "9000:9000"
      - "9001:9001"
    environment:
      - MINIO_ROOT_USER=${S3_ACCESS_KEY}
      - MINIO_ROOT_PASSWORD=${S3_SECRET_KEY}
    command: server /data --console-address ":9001"
    volumes:
      - minio-data:/data
+   healthcheck:
+     test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
+     interval: 10s
+     timeout: 5s
+     retries: 5
    networks:
      - cap-network

Then update cap-web's depends_on to enforce health checks:

    depends_on:
-     - db
-     - minio
+     db:
+       condition: service_healthy
+     minio:
+       condition: service_healthy
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
depends_on:
- db
- minio
networks:
- cap-network
depends_on:
db:
condition: service_healthy
minio:
condition: service_healthy
networks:
- cap-network
🤖 Prompt for AI Agents
In docker-compose.yml around lines 31 to 35, the compose file uses depends_on
without health checks which doesn't guarantee MySQL and MinIO are ready; add
healthcheck sections for the db service (a mysql client or simple TCP/port check
with retries/start_period/interval/timeout) and for the minio service (an HTTP
GET to /minio/health/ready or a TCP/port check with
retries/start_period/interval/timeout) and then change cap-web's depends_on
entry to depend on db and minio with condition: service_healthy so cap-web waits
until those healthchecks pass before starting.


# Die MySQL-Datenbank zur Speicherung von Metadaten
db:
image: mysql:8.0
restart: always
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
volumes:
# Speichert die Datenbankdaten persistent auf dem Host-System
- db-data:/var/lib/mysql
networks:
- cap-network

# MinIO als S3-kompatibler Speicher für die Videoaufnahmen
minio:
image: minio/minio:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Pin MinIO image version for reproducibility.

Using minio/minio:latest risks unpredictable behavior and breaking changes across deployments. Align with MySQL's version-pinning approach.

-    image: minio/minio:latest
+    image: minio/minio:2024.11.07
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
image: minio/minio:latest
image: minio/minio:2024.11.07
🤖 Prompt for AI Agents
In docker-compose.yml at line 54, the MinIO service uses the floating tag
"minio/minio:latest", which can lead to non-reproducible deployments; change it
to a specific, pinned MinIO tag (for example the tested release tag your project
uses) by replacing ":latest" with that exact version string, update any
deployment docs or environment files to record the chosen tag, and run a quick
compose up/down to verify compatibility.

restart: always
ports:
# Port für die S3-API
- "9000:9000"
# Port für die MinIO Web-UI
- "9001:9001"
environment:
- MINIO_ROOT_USER=${S3_ACCESS_KEY}
- MINIO_ROOT_PASSWORD=${S3_SECRET_KEY}
command: server /data --console-address ":9001"
volumes:
# Speichert die hochgeladenen Aufnahmen persistent auf dem Host-System
- minio-data:/data
networks:
- cap-network

# Definition der Volumes für persistente Datenspeicherung
volumes:
db-data:
minio-data:

# Definition des internen Netzwerks für die Kommunikation der Container
networks:
cap-network: