diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5ae231e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# Ignore everything +** + +# Allow system files and directories +!docker-utils/ +!system/ +!.htaccess +!composer* +!index.php + +# Allow content 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..ae4f2a8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ system/vendor plugins/demo zips build.php -node_modules \ No newline at end of file +node_modules +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e96f830 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +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 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/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/ && \ + 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 new file mode 100644 index 0000000..f3bacd9 --- /dev/null +++ b/docker-utils/init-server @@ -0,0 +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/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..f2d899a 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,49 @@ 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/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 +``` + +#### 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) +- `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) + + ## 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.