summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile13
-rw-r--r--docker-entrypoint.sh11
2 files changed, 20 insertions, 4 deletions
diff --git a/Dockerfile b/Dockerfile
index 2a31b2a..9309d26 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -30,16 +30,21 @@ RUN a2enmod rewrite
30RUN echo "upload_max_filesize = 50M" > /usr/local/etc/php/conf.d/sent-web.ini \ 30RUN 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
34COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
35RUN chmod +x /usr/local/bin/docker-entrypoint.sh
36
33# copy application 37# copy application
34COPY src/ /var/www/html/src/ 38COPY 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
37RUN mkdir -p /var/www/html/src/uploads \ 41RUN 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
40EXPOSE 3000 45EXPOSE 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
44ENTRYPOINT ["/usr/bin/tini", "--"] 49ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint.sh"]
45CMD ["apache2-foreground"] \ No newline at end of file 50CMD ["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
2set -e
3
4if [ -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/
7fi
8
9chown -R www-data:www-data /var/www/html/src/uploads
10
11exec "$@" \ No newline at end of file