Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]
7 changes: 4 additions & 3 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 "$@"