From a967d1b6ab61cbebbf3eb1e83bf38750a957fde1 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sun, 15 Mar 2026 14:19:44 +0000 Subject: [PATCH] Add auto cache clear and rebuild on deploy --- Dockerfile | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b1936099e8..18fed7b57f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,39 @@ FROM espocrm/espocrm:latest # Copy custom extensions and modifications COPY custom/ /var/www/html/custom/ -# Ensure correct permissions for custom dir +# Ensure correct permissions RUN chown -R www-data:www-data /var/www/html/custom +# Post-deploy: clear cache and rebuild on startup +COPY --chmod=755 <<'EOF' /usr/local/bin/post-deploy.sh +#!/bin/bash +set -e + +# Wait for the original entrypoint to finish setup +sleep 5 + +# Clear cache so EspoCRM picks up new/changed extensions +if [ -d "/var/www/html/data/cache" ]; then + rm -rf /var/www/html/data/cache/* + echo "Cache cleared." +fi + +# Run rebuild if config exists (means EspoCRM is installed) +if [ -f "/var/www/html/data/config.php" ]; then + cd /var/www/html + php rebuild.php + echo "Rebuild complete." +fi +EOF + +# Wrap the original entrypoint to run post-deploy after startup +COPY --chmod=755 <<'EOF' /usr/local/bin/dev-entrypoint.sh +#!/bin/bash +# Run post-deploy in background after container starts +(post-deploy.sh &) +# Execute original entrypoint +exec docker-entrypoint.sh apache2-foreground +EOF + EXPOSE 80 +ENTRYPOINT ["dev-entrypoint.sh"]