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"]