Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Share the cache volume between web and worker in compose
Guido Boyke61e33a2c6939
diff --git a/Dockerfile b/Dockerfileindex 7519263..7266d5d 100644--- a/Dockerfile+++ b/Dockerfile@@ -90,10 +90,12 @@ FROM baseCOPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"COPY --from=build /rails /rails-# Not root at run time. storage/ holds the uploads and is a volume in compose.yml.+# Not root at run time. storage/ holds the uploads and tmp/cache/store the+# Rails cache; both are volumes in compose.yml. Created here so a new volume+# takes their owner from the image.RUN groupadd --system --gid 1000 rails && \useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \- mkdir -p log storage tmp && \+ mkdir -p log storage tmp/cache/store && \chown -R rails:rails log storage tmpUSER 1000:1000diff --git a/compose.yml b/compose.ymlindex 1751fda..568019b 100644--- a/compose.yml+++ b/compose.yml@@ -14,13 +14,15 @@# To build the image from your checkout instead, see compose.build.yml.## Services: web (Puma), worker (Solid Queue), db (PostgreSQL with pgvector),-# redis (Action Cable and the cache; Valkey, a BSD-licensed Redis fork) and+# redis (Action Cable; Valkey, a BSD-licensed Redis fork) and# caddy (TLS with an automatic certificate). Caddy only starts with the "tls"# profile, which .env.docker.example switches on; leave it off if a proxy of# your own terminates TLS, and point that proxy at 127.0.0.1:3000.#-# Data lives in three volumes: the database, uploaded files (storage) and-# Caddy's certificates. `docker compose down -v` deletes all of them.+# Data lives in four volumes: the database, uploaded files (storage), the+# Rails cache and Caddy's certificates. `docker compose down -v` deletes all+# of them. The cache is shared by web and worker: the worker's hourly+# CacheCleanupJob deletes the expired entries the web container wrote.x-app: &appimage: ghcr.io/lalabase/lalabase:${LALABASE_VERSION:-2026.11.0}@@ -47,6 +49,7 @@ x-app: &appRAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-3}volumes:- storage:/rails/storage+ - cache:/rails/tmp/cache/storedepends_on:db:condition: service_healthy@@ -120,4 +123,5 @@ services:volumes:db:storage:+ cache:caddy:diff --git a/script/docker_check b/script/docker_checkindex fd5ed2b..fcc3327 100755--- a/script/docker_check+++ b/script/docker_check@@ -104,4 +104,20 @@ test "$(docker compose ps worker --format '{{.State}}')" = "running"# the cut-off logs command would turn a passing check red.grep -q 'Started Worker' <<<"$(docker compose logs worker)"+# The worker sweeps the cache the web container writes (CacheCleanupJob):+# both must mount the same store. An entry the web writes has to be visible+# in the worker, and gone for the web once the worker swept it.+echo "Worker sweeps the cache of the web container"+cache_file='Rails.cache.send(:normalize_key, "docker_check", nil)'+docker compose exec -T web bin/rails runner \+ "Rails.cache.write('docker_check', 1, expires_in: 1)"+docker compose exec -T worker bin/rails runner \+ "exit(File.exist?(${cache_file}) ? 0 : 1)" ||+ { echo "::error::The worker does not see the web container's cache"; exit 1; }+sleep 2+docker compose exec -T worker bin/rails runner 'CacheCleanupJob.perform_now'+docker compose exec -T web bin/rails runner \+ "exit(File.exist?(${cache_file}) ? 1 : 0)" ||+ { echo "::error::An expired entry of the web container survived the sweep"; exit 1; }+echo "Docker check passed."