diff --git a/Dockerfile b/Dockerfile index c583d42..7ceefb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,9 @@ ## base FROM ghcr.io/eramba/php:8.1-apache as base +# Install rsync +RUN apt-get update && apt-get install -y rsync + # Setup vhost COPY ./docker/apache/vhost.conf /etc/apache2/sites-available/000-default.conf @@ -46,23 +49,13 @@ RUN chown www-data: -R /var/www/ ## app FROM base as eramba -ARG COMPOSER=composer.json -ARG UID=33 -ARG GID=33 ARG UNAME=www-data -## To be able to specify composer.json file for a build. -ENV COMPOSER=${COMPOSER} - COPY ./docker/docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh COPY --chown=$UNAME:$UNAME . /var/www/eramba - -RUN --mount=type=ssh,uid=$UID,gid=$GID su -s /bin/bash -c "mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts" $UNAME -RUN --mount=type=ssh,uid=$UID,gid=$GID su -s /bin/bash -c "ssh -T git@github.com 2>&1 | tee /dev/null" $UNAME -RUN --mount=type=ssh,uid=$UID,gid=$GID su -s /bin/bash -c "cd /var/www/eramba && php composer.phar clearcache" $UNAME -RUN --mount=type=ssh,uid=$UID,gid=$GID su -s /bin/bash -c "cd /var/www/eramba && php composer.phar install --prefer-dist --no-interaction --ignore-platform-reqs" $UNAME +RUN su -s /bin/bash -c "cd /var/www/eramba && php composer.phar run-script post-install-cmd --no-interaction" $UNAME ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["apache2-foreground"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 35aa60c..a47a852 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,9 +1,10 @@ #!/bin/sh -# chown www-data: -R /var/www - cd /var/www/eramba || exit +# syncing dir structure into /data folder from /data_template +su -s /bin/bash -c "rsync -rv app/upgrade/data_template/ app/upgrade/data/" www-data + # when deploying a code or DB migration change and you want the "old workers" based on the old code # to not process any new incoming jobs after deployment. su -s /bin/bash -c "php app/upgrade/bin/cake.php queue worker end all -q" www-data @@ -20,6 +21,6 @@ su -s /bin/bash -c "php app/upgrade/bin/cake.php database initialize" www-data su -s /bin/bash -c "php app/upgrade/bin/cake.php setup.maintenance_mode deactivate" www-data # Initialize a worker with the deployment so we won't have to wait for the cron to kick in which can take up to 10 minutes. -su -s /bin/bash -c "php app/upgrade/bin/cake.php queue run -v" www-data 2>&1 & +su -s /bin/bash -c "php app/upgrade/bin/cake.php queue run -v" www-data 2>&1 & exec docker-php-entrypoint "$@"