From 487b8e3a892605ea6e6f3ad73688ef3161c7be6b Mon Sep 17 00:00:00 2001 From: matbgn Date: Wed, 18 May 2022 21:01:19 +0200 Subject: [PATCH 01/11] Docker first non-working attempt --- .dockerignore | 21 +++++++++++ .gitignore | 4 +- Dockerfile | 70 +++++++++++++++++++++++++++++++++++ docker-utils/adjust-rights | 17 +++++++++ docker-utils/init-server | 16 ++++++++ docker-utils/install-composer | 17 +++++++++ readme.md | 6 ++- system/system.php | 2 +- 8 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-utils/adjust-rights create mode 100644 docker-utils/init-server create mode 100644 docker-utils/install-composer diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..238da74 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# Ignore everything +** + +# Allow system files and directories +!docker-utils/ +!system/ +!.htaccess +!composer* +!index.php + +# Allow example files and directories +!cache/ +!content/ +!data/ +!media/ +!settings/ +!themes/ + +# Ignore unnecessary files inside allowed directories below +# This should go after the allowed directories +# e.g. docker-utils/test.php diff --git a/.gitignore b/.gitignore index 902f6fe..eb781af 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ system/vendor plugins/demo zips build.php -node_modules \ No newline at end of file +node_modules +.idea +dist \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ef1bcf4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,70 @@ +FROM php:8-apache + +# Install OS dependencies required +RUN apt-get update && apt-get upgrade -y && apt-get install git unzip zlib1g-dev libpng-dev -y + +# Adapt apache config +RUN a2enmod rewrite \ + && echo "ServerName 127.0.0.1" >> /etc/apache2/apache2.conf + +# Install PHP ext-gd +RUN docker-php-ext-install gd + +COPY docker-utils /usr/local/bin + +WORKDIR /src + +COPY system ./system +COPY .htaccess \ + composer* \ + index.php \ + /src/ +COPY cache ./cache +COPY data ./data +COPY media ./media +COPY settings ./settings +COPY themes ./themes + +RUN chmod +x /usr/local/bin/install-composer && \ + /usr/local/bin/install-composer && \ + ./composer.phar update && \ + chmod +x /usr/local/bin/init-server && \ + chmod +x /usr/local/bin/adjust-rights + +WORKDIR /tmp + +COPY content ./content + +# Create a non-root user to own the files and run our server +WORKDIR /var/www/html + +# Expose single volume of data to simplify maintenance +VOLUME /var/www/html + +#RUN cp -R /src/* /var/www/html/ +#RUN cp -R /tmp/* /var/www/html/ +#ARG UNAME=www-data +#ARG UGROUP=www-data +#ENV UID=1000 +#ENV GID=1000 +#RUN usermod --uid $UID $UNAME && \ +# groupmod --gid $GID $UGROUP + +# Install PHP dependencies +#RUN /usr/local/bin/install-composer && \ +# ./composer.phar update && \ +# rm -rf composer* Dockerfile docker-utils/install-composer +# +## Adjust rights for www-data, a non-root user, to own the files and run our server +#RUN /usr/local/bin/adjust-rights && \ +# rm -rf Dockerfile + + +#RUN sed -i 's/^exec /chown www-data:www-data \/var\/www\/html/\n\nexec /' /usr/local/bin/apache2-foreground +# +### Use our non-root user +#RUN chown -R www-data:www-data /var/www/html/ +#USER www-data + +# Run the server +CMD ["/usr/local/bin/init-server"] \ No newline at end of file diff --git a/docker-utils/adjust-rights b/docker-utils/adjust-rights new file mode 100644 index 0000000..a05cf08 --- /dev/null +++ b/docker-utils/adjust-rights @@ -0,0 +1,17 @@ +#!/bin/sh + +chown -R www-data:www-data /var/www/html +find /var/www/html -type d -exec chmod 570 {} \; +find /var/www/html -type f -exec chmod 460 {} \; +chown -R www-data:www-data /var/www/html/cache +find /var/www/html/cache -type d -exec chmod 770 {} \; +find /var/www/html/cache -type f -exec chmod 660 {} \; +chown -R www-data:www-data /var/www/html/content +find /var/www/html/content -type d -exec chmod 770 {} \; +find /var/www/html/content -type f -exec chmod 660 {} \; +chown -R www-data:www-data /var/www/html/media +find /var/www/html/media -type d -exec chmod 770 {} \; +find /var/www/html/media -type f -exec chmod 660 {} \; +chown -R www-data:www-data /var/www/html/settings +find /var/www/html/settings -type d -exec chmod 770 {} \; +find /var/www/html/settings -type f -exec chmod 660 {} \; \ No newline at end of file diff --git a/docker-utils/init-server b/docker-utils/init-server new file mode 100644 index 0000000..2933aad --- /dev/null +++ b/docker-utils/init-server @@ -0,0 +1,16 @@ +#!/bin/sh + +find /var/www/html -type d -empty -exec cp -R /tmp/* /var/www/html/ \; + +cp -R /src/* /var/www/html/ +cp -R /tmp/* /var/www/html/ + +/usr/local/bin/install-composer && \ +./composer.phar update + +usermod -u $PUID www-data +groupmod -g $PGID www-data + +/usr/local/bin/adjust-rights + +apache2-foreground \ No newline at end of file diff --git a/docker-utils/install-composer b/docker-utils/install-composer new file mode 100644 index 0000000..585031d --- /dev/null +++ b/docker-utils/install-composer @@ -0,0 +1,17 @@ +#!/bin/sh + +EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" + +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ] +then + >&2 echo 'ERROR: Invalid installer checksum' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +RESULT=$? +rm composer-setup.php +exit $RESULT \ No newline at end of file diff --git a/readme.md b/readme.md index 0fbd9ce..ca016fa 100644 --- a/readme.md +++ b/readme.md @@ -41,6 +41,7 @@ Some plugin highlights are: If you run a linux system, then please double check that mod_rewrite and htaccess are active!!! ## Installation +### Bare-metal installation Download TYPEMILL from the [TYPEMILL website](http://typemill.net), unzip the files and you are done. @@ -56,7 +57,7 @@ If you did not use composer before, please go to the [composer website](http://g To run TYPEMILL on a **live** system, simply upload the files to your server -## Make Folders Writable. +#### Make Folders Writable. Make sure that the following folders and all their files are writable (permission 774 recursively): @@ -67,6 +68,9 @@ Make sure that the following folders and all their files are writable (permissio You can use your ftp-software for that. +### Docker installation + + ## Setup If you visit your website first, then you will be redirected to the `/setup` page. Please create an initial user and configure your system in the author panel. diff --git a/system/system.php b/system/system.php index 62829c7..e02c00d 100644 --- a/system/system.php +++ b/system/system.php @@ -29,7 +29,7 @@ $settings = Typemill\Settings::loadSettings(); /**************************** * HANDLE DISPLAY ERRORS * ****************************/ - +$settings['settings']['displayErrorDetails'] = true; if(isset($settings['settings']['displayErrorDetails']) && $settings['settings']['displayErrorDetails']) { ini_set('display_errors', 1); From 24b1042545285eed00a42a70937bf07a2d1fd062 Mon Sep 17 00:00:00 2001 From: matbgn Date: Wed, 18 May 2022 22:04:02 +0200 Subject: [PATCH 02/11] Functional without volume --- Dockerfile | 42 ++++++++++++++++++++++---------------- docker-utils/adjust-rights | 7 ++++--- docker-utils/init-server | 19 +++++++++-------- system/system.php | 2 +- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index ef1bcf4..bb8ad86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,34 +12,40 @@ RUN docker-php-ext-install gd COPY docker-utils /usr/local/bin -WORKDIR /src +#WORKDIR /src +# +#COPY system ./system +#COPY .htaccess \ +# composer* \ +# index.php \ +# /src/ +#COPY cache ./cache +#COPY data ./data +#COPY media ./media +#COPY settings ./settings +#COPY themes ./themes -COPY system ./system -COPY .htaccess \ - composer* \ - index.php \ - /src/ -COPY cache ./cache -COPY data ./data -COPY media ./media -COPY settings ./settings -COPY themes ./themes +#WORKDIR /tmp +# +#COPY content ./content + +WORKDIR /var/www/html +COPY . /src/ +COPY . . RUN chmod +x /usr/local/bin/install-composer && \ /usr/local/bin/install-composer && \ ./composer.phar update && \ - chmod +x /usr/local/bin/init-server && \ - chmod +x /usr/local/bin/adjust-rights + chmod +x /usr/local/bin/init-server +# chmod +x /usr/local/bin/adjust-rights && \ +# /usr/local/bin/adjust-rights -WORKDIR /tmp - -COPY content ./content # Create a non-root user to own the files and run our server -WORKDIR /var/www/html +#WORKDIR /var/www/html # Expose single volume of data to simplify maintenance -VOLUME /var/www/html +#VOLUME /var/www/html/content #RUN cp -R /src/* /var/www/html/ #RUN cp -R /tmp/* /var/www/html/ diff --git a/docker-utils/adjust-rights b/docker-utils/adjust-rights index a05cf08..5993c61 100644 --- a/docker-utils/adjust-rights +++ b/docker-utils/adjust-rights @@ -1,8 +1,9 @@ #!/bin/sh -chown -R www-data:www-data /var/www/html -find /var/www/html -type d -exec chmod 570 {} \; -find /var/www/html -type f -exec chmod 460 {} \; +#chown -R www-data:www-data /var/www/html +#find /var/www/html -type d -exec chmod 570 {} \; +#find /var/www/html -type f -exec chmod 460 {} \; +echo TestMBO1 chown -R www-data:www-data /var/www/html/cache find /var/www/html/cache -type d -exec chmod 770 {} \; find /var/www/html/cache -type f -exec chmod 660 {} \; diff --git a/docker-utils/init-server b/docker-utils/init-server index 2933aad..91245b0 100644 --- a/docker-utils/init-server +++ b/docker-utils/init-server @@ -1,16 +1,17 @@ #!/bin/sh -find /var/www/html -type d -empty -exec cp -R /tmp/* /var/www/html/ \; +#usermod -u $PUID www-data +#groupmod -g $PGID www-data +#find /var/www/html -type d -empty -exec cp -R /tmp/* /var/www/html/ \; +# +#cp -R /src/* /var/www/html/ +#cp -R /tmp/* /var/www/html/ -cp -R /src/* /var/www/html/ -cp -R /tmp/* /var/www/html/ +#/usr/local/bin/install-composer && \ +#./composer.phar update -/usr/local/bin/install-composer && \ -./composer.phar update -usermod -u $PUID www-data -groupmod -g $PGID www-data - -/usr/local/bin/adjust-rights +chown www-data:www-data /var/www/html/ +#/usr/local/bin/adjust-rights apache2-foreground \ No newline at end of file diff --git a/system/system.php b/system/system.php index e02c00d..cd33c34 100644 --- a/system/system.php +++ b/system/system.php @@ -29,7 +29,7 @@ $settings = Typemill\Settings::loadSettings(); /**************************** * HANDLE DISPLAY ERRORS * ****************************/ -$settings['settings']['displayErrorDetails'] = true; +//$settings['settings']['displayErrorDetails'] = true; if(isset($settings['settings']['displayErrorDetails']) && $settings['settings']['displayErrorDetails']) { ini_set('display_errors', 1); From 15b74135c9f5965178e9c63d55967d312455e695 Mon Sep 17 00:00:00 2001 From: matbgn Date: Wed, 18 May 2022 22:31:24 +0200 Subject: [PATCH 03/11] Working solution with aurel-g solution and sub-volume under var/www/html --- .dockerignore | 3 +++ Dockerfile | 11 ++++++++++- docker-utils/init-server | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 238da74..9565dc7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,6 +8,9 @@ !composer* !index.php +!cmd.sh +!init_content.sh + # Allow example files and directories !cache/ !content/ diff --git a/Dockerfile b/Dockerfile index bb8ad86..9e8f52c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,15 @@ RUN chmod +x /usr/local/bin/install-composer && \ # chmod +x /usr/local/bin/adjust-rights && \ # /usr/local/bin/adjust-rights +RUN chown -R www-data:www-data /var/www/html \ + && find /var/www/html -type d -exec chmod 570 {} \; \ + && find /var/www/html -type f -exec chmod 460 {} \; +RUN cp -R /var/www/html/content /var/www/html/content.orig +COPY cmd.sh / +COPY init_content.sh / +RUN chown root:root /cmd.sh ; chmod 0700 /cmd.sh +RUN chown root:root /init_content.sh ; chmod 0700 /init_content.sh +CMD ["/cmd.sh"] # Create a non-root user to own the files and run our server #WORKDIR /var/www/html @@ -73,4 +82,4 @@ RUN chmod +x /usr/local/bin/install-composer && \ #USER www-data # Run the server -CMD ["/usr/local/bin/init-server"] \ No newline at end of file +#CMD ["/usr/local/bin/init-server"] \ No newline at end of file diff --git a/docker-utils/init-server b/docker-utils/init-server index 91245b0..8356607 100644 --- a/docker-utils/init-server +++ b/docker-utils/init-server @@ -4,7 +4,7 @@ #groupmod -g $PGID www-data #find /var/www/html -type d -empty -exec cp -R /tmp/* /var/www/html/ \; # -#cp -R /src/* /var/www/html/ +cp -R /src/* /var/www/html/ #cp -R /tmp/* /var/www/html/ #/usr/local/bin/install-composer && \ From 867897696ba647c9a0c7564b623d2204dbe5ba34 Mon Sep 17 00:00:00 2001 From: matbgn Date: Wed, 18 May 2022 22:31:58 +0200 Subject: [PATCH 04/11] Add missing files from aurel-g solution --- cmd.sh | 20 ++++++++++++++++++++ init_content.sh | 5 +++++ 2 files changed, 25 insertions(+) create mode 100644 cmd.sh create mode 100644 init_content.sh diff --git a/cmd.sh b/cmd.sh new file mode 100644 index 0000000..e1f2b3d --- /dev/null +++ b/cmd.sh @@ -0,0 +1,20 @@ +#!/bin/bash +find /var/www/html/content -maxdepth 0 -empty -exec /init_content.sh \; +if [ "$TYPEMILL_UID" ] || [ "$TYPEMILL_GID" ]; then + usermod -u $TYPEMILL_UID www-data + groupmod -g $TYPEMILL_GID www-data + chown -R www-data:www-data /var/www/html +fi +chown -R www-data:www-data /var/www/html/cache +find /var/www/html/cache -type d -exec chmod 770 {} \; +find /var/www/html/cache -type f -exec chmod 660 {} \; +chown -R www-data:www-data /var/www/html/content +find /var/www/html/content -type d -exec chmod 770 {} \; +find /var/www/html/content -type f -exec chmod 660 {} \; +chown -R www-data:www-data /var/www/html/media +find /var/www/html/media -type d -exec chmod 770 {} \; +find /var/www/html/media -type f -exec chmod 660 {} \; +chown -R www-data:www-data /var/www/html/settings +find /var/www/html/settings -type d -exec chmod 770 {} \; +find /var/www/html/settings -type f -exec chmod 660 {} \; +apache2-foreground diff --git a/init_content.sh b/init_content.sh new file mode 100644 index 0000000..f17a5a3 --- /dev/null +++ b/init_content.sh @@ -0,0 +1,5 @@ +#!/bin/bash +echo "**************************************************************************" +echo "! Content directory is empty. It will be initialized with default content." +echo "**************************************************************************" +cp -R /var/www/html/content.orig/* /var/www/html/content/ From 106b0d143a9834e223c311afe5be257eb5e9ba14 Mon Sep 17 00:00:00 2001 From: matbgn Date: Wed, 18 May 2022 23:48:31 +0200 Subject: [PATCH 05/11] Massive refactor to switch on own solution --- Dockerfile | 71 +++------------------------------------- docker-utils/init-server | 16 +-------- 2 files changed, 5 insertions(+), 82 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9e8f52c..8256ca9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,76 +10,13 @@ RUN a2enmod rewrite \ # Install PHP ext-gd RUN docker-php-ext-install gd -COPY docker-utils /usr/local/bin - -#WORKDIR /src -# -#COPY system ./system -#COPY .htaccess \ -# composer* \ -# index.php \ -# /src/ -#COPY cache ./cache -#COPY data ./data -#COPY media ./media -#COPY settings ./settings -#COPY themes ./themes - -#WORKDIR /tmp -# -#COPY content ./content - WORKDIR /var/www/html -COPY . /src/ COPY . . -RUN chmod +x /usr/local/bin/install-composer && \ - /usr/local/bin/install-composer && \ +RUN chmod +x /var/www/html/docker-utils/install-composer && \ + /var/www/html/docker-utils/install-composer && \ ./composer.phar update && \ - chmod +x /usr/local/bin/init-server -# chmod +x /usr/local/bin/adjust-rights && \ -# /usr/local/bin/adjust-rights - -RUN chown -R www-data:www-data /var/www/html \ - && find /var/www/html -type d -exec chmod 570 {} \; \ - && find /var/www/html -type f -exec chmod 460 {} \; -RUN cp -R /var/www/html/content /var/www/html/content.orig -COPY cmd.sh / -COPY init_content.sh / -RUN chown root:root /cmd.sh ; chmod 0700 /cmd.sh -RUN chown root:root /init_content.sh ; chmod 0700 /init_content.sh -CMD ["/cmd.sh"] - -# Create a non-root user to own the files and run our server -#WORKDIR /var/www/html - -# Expose single volume of data to simplify maintenance -#VOLUME /var/www/html/content - -#RUN cp -R /src/* /var/www/html/ -#RUN cp -R /tmp/* /var/www/html/ -#ARG UNAME=www-data -#ARG UGROUP=www-data -#ENV UID=1000 -#ENV GID=1000 -#RUN usermod --uid $UID $UNAME && \ -# groupmod --gid $GID $UGROUP - -# Install PHP dependencies -#RUN /usr/local/bin/install-composer && \ -# ./composer.phar update && \ -# rm -rf composer* Dockerfile docker-utils/install-composer -# -## Adjust rights for www-data, a non-root user, to own the files and run our server -#RUN /usr/local/bin/adjust-rights && \ -# rm -rf Dockerfile - - -#RUN sed -i 's/^exec /chown www-data:www-data \/var\/www\/html/\n\nexec /' /usr/local/bin/apache2-foreground -# -### Use our non-root user -#RUN chown -R www-data:www-data /var/www/html/ -#USER www-data + chmod +x /var/www/html/docker-utils/init-server # Run the server -#CMD ["/usr/local/bin/init-server"] \ No newline at end of file +CMD ["/var/www/html/docker-utils/init-server"] \ No newline at end of file diff --git a/docker-utils/init-server b/docker-utils/init-server index 8356607..c7a35b3 100644 --- a/docker-utils/init-server +++ b/docker-utils/init-server @@ -1,17 +1,3 @@ #!/bin/sh - -#usermod -u $PUID www-data -#groupmod -g $PGID www-data -#find /var/www/html -type d -empty -exec cp -R /tmp/* /var/www/html/ \; -# -cp -R /src/* /var/www/html/ -#cp -R /tmp/* /var/www/html/ - -#/usr/local/bin/install-composer && \ -#./composer.phar update - - -chown www-data:www-data /var/www/html/ -#/usr/local/bin/adjust-rights - +chown -R www-data:www-data /var/www/html/ apache2-foreground \ No newline at end of file From 5d8d4d7d5987eedd9d57e7f99441636dc9d89e5b Mon Sep 17 00:00:00 2001 From: matbgn Date: Wed, 18 May 2022 23:58:03 +0200 Subject: [PATCH 06/11] Working solution with or without anonymous volumes --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 8256ca9..c71838f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,5 +18,7 @@ RUN chmod +x /var/www/html/docker-utils/install-composer && \ ./composer.phar update && \ chmod +x /var/www/html/docker-utils/init-server +VOLUME /var/www/html/settings + # Run the server CMD ["/var/www/html/docker-utils/init-server"] \ No newline at end of file From 9479a4ed4d97454c15f179ab350bb0289b849c44 Mon Sep 17 00:00:00 2001 From: matbgn Date: Thu, 19 May 2022 00:08:26 +0200 Subject: [PATCH 07/11] Add anonymous persistence to all possible volumes --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index c71838f..eff0867 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,10 @@ RUN chmod +x /var/www/html/docker-utils/install-composer && \ chmod +x /var/www/html/docker-utils/init-server VOLUME /var/www/html/settings +VOLUME /var/www/html/content +VOLUME /var/www/html/media +VOLUME /var/www/html/themes +VOLUME /var/www/html/cache # Run the server CMD ["/var/www/html/docker-utils/init-server"] \ No newline at end of file From 2932b457e9654cc5fb6ec8c8bb531411b9841183 Mon Sep 17 00:00:00 2001 From: matbgn Date: Thu, 19 May 2022 00:13:06 +0200 Subject: [PATCH 08/11] Reduce impacted files before merge --- .dockerignore | 5 +---- .gitignore | 3 +-- cmd.sh | 20 -------------------- docker-utils/adjust-rights | 18 ------------------ init_content.sh | 5 ----- system/system.php | 2 +- 6 files changed, 3 insertions(+), 50 deletions(-) delete mode 100644 cmd.sh delete mode 100644 docker-utils/adjust-rights delete mode 100644 init_content.sh diff --git a/.dockerignore b/.dockerignore index 9565dc7..5ae231e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,10 +8,7 @@ !composer* !index.php -!cmd.sh -!init_content.sh - -# Allow example files and directories +# Allow content files and directories !cache/ !content/ !data/ diff --git a/.gitignore b/.gitignore index eb781af..ae4f2a8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,4 @@ plugins/demo zips build.php node_modules -.idea -dist \ No newline at end of file +.idea \ No newline at end of file diff --git a/cmd.sh b/cmd.sh deleted file mode 100644 index e1f2b3d..0000000 --- a/cmd.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -find /var/www/html/content -maxdepth 0 -empty -exec /init_content.sh \; -if [ "$TYPEMILL_UID" ] || [ "$TYPEMILL_GID" ]; then - usermod -u $TYPEMILL_UID www-data - groupmod -g $TYPEMILL_GID www-data - chown -R www-data:www-data /var/www/html -fi -chown -R www-data:www-data /var/www/html/cache -find /var/www/html/cache -type d -exec chmod 770 {} \; -find /var/www/html/cache -type f -exec chmod 660 {} \; -chown -R www-data:www-data /var/www/html/content -find /var/www/html/content -type d -exec chmod 770 {} \; -find /var/www/html/content -type f -exec chmod 660 {} \; -chown -R www-data:www-data /var/www/html/media -find /var/www/html/media -type d -exec chmod 770 {} \; -find /var/www/html/media -type f -exec chmod 660 {} \; -chown -R www-data:www-data /var/www/html/settings -find /var/www/html/settings -type d -exec chmod 770 {} \; -find /var/www/html/settings -type f -exec chmod 660 {} \; -apache2-foreground diff --git a/docker-utils/adjust-rights b/docker-utils/adjust-rights deleted file mode 100644 index 5993c61..0000000 --- a/docker-utils/adjust-rights +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -#chown -R www-data:www-data /var/www/html -#find /var/www/html -type d -exec chmod 570 {} \; -#find /var/www/html -type f -exec chmod 460 {} \; -echo TestMBO1 -chown -R www-data:www-data /var/www/html/cache -find /var/www/html/cache -type d -exec chmod 770 {} \; -find /var/www/html/cache -type f -exec chmod 660 {} \; -chown -R www-data:www-data /var/www/html/content -find /var/www/html/content -type d -exec chmod 770 {} \; -find /var/www/html/content -type f -exec chmod 660 {} \; -chown -R www-data:www-data /var/www/html/media -find /var/www/html/media -type d -exec chmod 770 {} \; -find /var/www/html/media -type f -exec chmod 660 {} \; -chown -R www-data:www-data /var/www/html/settings -find /var/www/html/settings -type d -exec chmod 770 {} \; -find /var/www/html/settings -type f -exec chmod 660 {} \; \ No newline at end of file diff --git a/init_content.sh b/init_content.sh deleted file mode 100644 index f17a5a3..0000000 --- a/init_content.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -echo "**************************************************************************" -echo "! Content directory is empty. It will be initialized with default content." -echo "**************************************************************************" -cp -R /var/www/html/content.orig/* /var/www/html/content/ diff --git a/system/system.php b/system/system.php index cd33c34..62829c7 100644 --- a/system/system.php +++ b/system/system.php @@ -29,7 +29,7 @@ $settings = Typemill\Settings::loadSettings(); /**************************** * HANDLE DISPLAY ERRORS * ****************************/ -//$settings['settings']['displayErrorDetails'] = true; + if(isset($settings['settings']['displayErrorDetails']) && $settings['settings']['displayErrorDetails']) { ini_set('display_errors', 1); From 505f36b0b9f7b900fc924b480ca243beab9630b6 Mon Sep 17 00:00:00 2001 From: matbgn Date: Thu, 19 May 2022 00:55:08 +0200 Subject: [PATCH 09/11] Add basic documentation to docker installation + initialize empty folders for themes and content --- Dockerfile | 17 ++++++++++++++--- docker-utils/init-server | 2 ++ readme.md | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index eff0867..21823cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,19 +10,30 @@ RUN a2enmod rewrite \ # Install PHP ext-gd RUN docker-php-ext-install gd +# Copy app content +# Use the .dockerignore file to control what ends up inside the image! WORKDIR /var/www/html COPY . . +# Install server dependencies RUN chmod +x /var/www/html/docker-utils/install-composer && \ /var/www/html/docker-utils/install-composer && \ ./composer.phar update && \ chmod +x /var/www/html/docker-utils/init-server +# Expose useful volumes (see documentation) VOLUME /var/www/html/settings -VOLUME /var/www/html/content VOLUME /var/www/html/media -VOLUME /var/www/html/themes VOLUME /var/www/html/cache -# Run the server +# Create a default copy of content and theme in case of empty directories binding +RUN mkdir -p /var/www/html/content.default/ && \ + cp -R /var/www/html/content/* /var/www/html/content.default/ && \ + mkdir -p /var/www/html/themes.default/ && \ + cp -R /var/www/html/themes/* /var/www/html/themes.default/ + +VOLUME /var/www/html/content +VOLUME /var/www/html/themes + +# Inject default values if content and themes are mounted with empty directories, adjust rights and start the server CMD ["/var/www/html/docker-utils/init-server"] \ No newline at end of file diff --git a/docker-utils/init-server b/docker-utils/init-server index c7a35b3..f3bacd9 100644 --- a/docker-utils/init-server +++ b/docker-utils/init-server @@ -1,3 +1,5 @@ #!/bin/sh +find /var/www/html/content -type d -empty -exec cp -R /var/www/html/content.default/* /var/www/html/content \; +find /var/www/html/themes -type d -empty -exec cp -R /var/www/html/themes.default/* /var/www/html/themes \; chown -R www-data:www-data /var/www/html/ apache2-foreground \ No newline at end of file diff --git a/readme.md b/readme.md index ca016fa..1634515 100644 --- a/readme.md +++ b/readme.md @@ -69,6 +69,44 @@ Make sure that the following folders and all their files are writable (permissio You can use your ftp-software for that. ### Docker installation +> :warning: This image does not provide TLS support. It's perfect either for local use or behind your own proxy, you're advised. + +Clone and edit the config.example.php you find in this repository and move it as config.php +``` +git clone git://github.com/trendschau/typemill.git +cd typemill +``` + +Build your image locally +``` +docker build -t typemill:local . +``` + +Run the docker image without persistence on port 8080 +``` +docker run -d --name typemill -p 8080:80 typemill:local +``` + +Run typemill with persistence +``` +docker run -d \ + --name=typemill \ + -p 8080:80 \ + -v $(pwd)/typemill_data/settings/:/var/www/html/settings/ \ + -v $(pwd)/typemill_data/media/:/var/www/html/media/ \ + -v $(pwd)/typemill_data/cache/:/var/www/html/cache/ \ + -v $(pwd)/typemill_data/content/:/var/www/html/content/ \ + -v $(pwd)/typemill_data/themes/:/var/www/html/themes/ \ + typemill:local +``` + +#### Volumes + +- `settings` : persists users profiles, site configuration, etc. (empty by default) +- `media` : persists media files (empty by default) +- `cache` : persists cache files for performance purpose (optional and empty by default) +- `content` : persists content published (will be initialized with default examples if the binded volume is empty) +- `themes` : persists installed themes (will be initialized with default examples if the binded volume is empty) ## Setup From 73201fe4f7c02fc6c5e145db691129fa70440dbc Mon Sep 17 00:00:00 2001 From: matbgn Date: Thu, 19 May 2022 15:28:06 +0200 Subject: [PATCH 10/11] Add plugins folder for further installation --- Dockerfile | 1 + readme.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 21823cf..e96f830 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ RUN chmod +x /var/www/html/docker-utils/install-composer && \ VOLUME /var/www/html/settings VOLUME /var/www/html/media VOLUME /var/www/html/cache +VOLUME /var/www/html/plugins # Create a default copy of content and theme in case of empty directories binding RUN mkdir -p /var/www/html/content.default/ && \ diff --git a/readme.md b/readme.md index 1634515..f2d899a 100644 --- a/readme.md +++ b/readme.md @@ -95,6 +95,7 @@ docker run -d \ -v $(pwd)/typemill_data/settings/:/var/www/html/settings/ \ -v $(pwd)/typemill_data/media/:/var/www/html/media/ \ -v $(pwd)/typemill_data/cache/:/var/www/html/cache/ \ + -v $(pwd)/typemill_data/plugins/:/var/www/html/plugins/ \ -v $(pwd)/typemill_data/content/:/var/www/html/content/ \ -v $(pwd)/typemill_data/themes/:/var/www/html/themes/ \ typemill:local @@ -105,6 +106,7 @@ docker run -d \ - `settings` : persists users profiles, site configuration, etc. (empty by default) - `media` : persists media files (empty by default) - `cache` : persists cache files for performance purpose (optional and empty by default) +- `plugins` : persists installed plugins (optional and empty by default) - `content` : persists content published (will be initialized with default examples if the binded volume is empty) - `themes` : persists installed themes (will be initialized with default examples if the binded volume is empty) From 456fc01c22b5ca93408fdd4bb708b1b36236a75f Mon Sep 17 00:00:00 2001 From: matbgn Date: Thu, 2 Jun 2022 11:05:24 +0200 Subject: [PATCH 11/11] Stick php version to 8.0.x --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e96f830..b0870f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8-apache +FROM php:8.0-apache # Install OS dependencies required RUN apt-get update && apt-get upgrade -y && apt-get install git unzip zlib1g-dev libpng-dev -y