diff --git a/compose.template.yml b/compose.template.yml index 51f9582..578af6e 100644 --- a/compose.template.yml +++ b/compose.template.yml @@ -1,7 +1,27 @@ services: + init: + image: busybox:1.37.0 + user: root:root + command: /init.sh + restart: no + network_mode: none + volumes: + - ./init.sh:/init.sh:ro + # Used for resolving user and group names within the init script + - /etc/passwd:/etc/passwd:ro + - /etc/group:/etc/group:ro + # Mount all named volumes so they can be initialised + - minio_data:/minio_data:rw + - museum_data:/museum_data:rw + - postgres_data:/postgres_data:rw + labels: + diun.enable: "true" + diun.watch_repo: "true" + diun.include_tags: "latest" + museum: container_name: ente_museum - image: ghcr.io/ente-io/server:927c6a316f181c7901446311f0085593b346b336 + image: ghcr.io/ente/server:0137a0c754ac0fe4f2c4c7421727c349327eb990 restart: unless-stopped user: 2008:2008 # ente:ente environment: @@ -11,11 +31,14 @@ services: ports: - 8080:8080 # API depends_on: + init: + condition: service_completed_successfully + restart: true postgres: condition: service_healthy volumes: - ./museum.yaml:/museum.yaml:ro - - /mnt/ente_1/museum_data:/data:ro + - museum_data:/data:ro healthcheck: test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/ping"] interval: 60s @@ -39,7 +62,7 @@ services: web: container_name: ente_web - image: ghcr.io/ente-io/web + image: ghcr.io/ente/web restart: unless-stopped # user: 2008:2008 # ente:ente networks: @@ -68,6 +91,10 @@ services: image: postgres:15 restart: unless-stopped user: 2008:2008 # ente:ente + depends_on: + init: + condition: service_completed_successfully + restart: true networks: - ente_network secrets: @@ -83,7 +110,7 @@ services: start_interval: 1s volumes: - /etc/passwd:/etc/passwd:ro - - /mnt/ente_1/postgres_data:/var/lib/postgresql/data:rw + - postgres_data:/var/lib/postgresql/data:rw labels: diun.enable: "false" diun.watch_repo: "true" @@ -94,11 +121,15 @@ services: image: minio/minio:RELEASE.2025-09-07T16-13-09Z restart: unless-stopped user: 2008:2008 # ente:ente + depends_on: + init: + condition: service_completed_successfully + restart: true networks: - ente_network ports: - 3200:3200 # MinIO API - # Uncomment to enable MinIO Web UI + # Uncomment to enable MinIO Web UI # - 3201:3201 secrets: - minio_root_user @@ -108,7 +139,7 @@ services: MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password command: server /data --address ":3200" --console-address ":3201" volumes: - - /mnt/ente_1/minio_data:/data:rw + - minio_data:/data:rw post_start: - command: | sh -c ' @@ -131,6 +162,11 @@ services: diun.watch_repo: "true" diun.include_tags: "latest" +volumes: + minio_data: + museum_data: + postgres_data: + networks: ente_network: name: ente_network diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..662812e --- /dev/null +++ b/init.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +# Define a helper function that runs a command +# If the command fails, the script prints an error message +# and exits immediately. +run() { + # "$@" expands to all arguments passed to this function + # and preserves proper word splitting and quoting. + "$@" || { + echo "Error: command failed: $*" >&2 + exit 1 + } +} + +run chown ente:ente /minio_data +run chown ente:ente /museum_data +run chown ente:ente /postgres_data +