diff options
| -rw-r--r-- | Dockerfile | 13 | ||||
| -rw-r--r-- | docker-entrypoint.sh | 11 |
2 files changed, 20 insertions, 4 deletions
| @@ -30,16 +30,21 @@ RUN a2enmod rewrite | |||
| 30 | RUN echo "upload_max_filesize = 50M" > /usr/local/etc/php/conf.d/sent-web.ini \ | 30 | RUN echo "upload_max_filesize = 50M" > /usr/local/etc/php/conf.d/sent-web.ini \ |
| 31 | && echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/sent-web.ini | 31 | && echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/sent-web.ini |
| 32 | 32 | ||
| 33 | # copy entrypoint script | ||
| 34 | COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | ||
| 35 | RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
| 36 | |||
| 33 | # copy application | 37 | # copy application |
| 34 | COPY src/ /var/www/html/src/ | 38 | COPY src/ /var/www/html/src/ |
| 35 | 39 | ||
| 36 | # ensure uploads directory exists with correct permissions | 40 | # stash a seed copy of uploads so the entrypoint can populate a fresh volume |
| 37 | RUN mkdir -p /var/www/html/src/uploads \ | 41 | RUN mkdir -p /opt/uploads-seed \ |
| 38 | && chown -R www-data:www-data /var/www/html/src/uploads | 42 | && cp -r /var/www/html/src/uploads/. /opt/uploads-seed/ \ |
| 43 | && chown -R www-data:www-data /var/www/html/src/uploads /opt/uploads-seed | ||
| 39 | 44 | ||
| 40 | EXPOSE 3000 | 45 | EXPOSE 3000 |
| 41 | 46 | ||
| 42 | # tini as PID 1 ensures SIGTERM is properly forwarded to apache, | 47 | # tini as PID 1 ensures SIGTERM is properly forwarded to apache, |
| 43 | # preventing the 'permission denied' error on docker stop | 48 | # preventing the 'permission denied' error on docker stop |
| 44 | ENTRYPOINT ["/usr/bin/tini", "--"] | 49 | ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"] |
| 45 | CMD ["apache2-foreground"] \ No newline at end of file | 50 | CMD ["apache2-foreground"] \ No newline at end of file |
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..8ffba10 --- /dev/null +++ b/docker-entrypoint.sh | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | set -e | ||
| 3 | |||
| 4 | if [ -z "$(ls -A /var/www/html/src/uploads 2>/dev/null)" ] && \ | ||
| 5 | [ -d /opt/uploads-seed ]; then | ||
| 6 | cp -r /opt/uploads-seed/. /var/www/html/src/uploads/ | ||
| 7 | fi | ||
| 8 | |||
| 9 | chown -R www-data:www-data /var/www/html/src/uploads | ||
| 10 | |||
| 11 | exec "$@" \ No newline at end of file | ||
