From 907e94eefb6438a7add91d2b9268572dd570713c Mon Sep 17 00:00:00 2001 From: Maghin Date: Wed, 9 May 2018 13:48:10 +0200 Subject: [PATCH 1/5] Own branch for 2.9 --- 3.0/Dockerfile | 154 ------------------ 3.0/docker-entrypoint.sh | 105 ------------ 2.9/Dockerfile => Dockerfile | 0 docker-compose.yml | 2 +- ...cker-entrypoint.sh => docker-entrypoint.sh | 0 5 files changed, 1 insertion(+), 260 deletions(-) delete mode 100644 3.0/Dockerfile delete mode 100644 3.0/docker-entrypoint.sh rename 2.9/Dockerfile => Dockerfile (100%) rename 2.9/docker-entrypoint.sh => docker-entrypoint.sh (100%) diff --git a/3.0/Dockerfile b/3.0/Dockerfile deleted file mode 100644 index 1e3ba50..0000000 --- a/3.0/Dockerfile +++ /dev/null @@ -1,154 +0,0 @@ -# -# This image uses 2 interstage and an php:7.1-apache final stage -# -# Interstages are: -# - composer -# - npm & yarn & grunt -# -# Final stage gets all that generated stuff and add it to the final image -# - -############################ -#=== composer interstage === -############################ -FROM composer:latest as composer -WORKDIR /app - -#=== Get PMF source code === -ARG PMF_BRANCH="2.9" -RUN set -x \ - && git clone \ - --depth 1 \ - -b $PMF_BRANCH \ - https://github.com/thorsten/phpMyFAQ.git \ - /app - -#=== Call composer === -RUN set -x \ - && composer install --no-dev - -######################## -#=== yarn interstage === -######################## -FROM node:latest as yarn -WORKDIR /app - -#=== Get PMF source code from previous stage === -COPY --from=composer /app /app - -#=== Install dependencies === -RUN set -x \ - && npm install node-sass -g --unsafe-perm - -#=== Build assets === -RUN set -x \ - && yarn install \ - && yarn build - -################################# -#=== Final stage with payload === -################################# -FROM php:7.1-apache - -#=== Install gd php dependencie === -RUN set -x \ - && buildDeps="libpng-dev libjpeg-dev libfreetype6-dev" \ - && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ - \ - && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ - && docker-php-ext-install gd \ - \ - && apt-get purge -y ${buildDeps} \ - && rm -rf /var/lib/apt/lists/* - -#=== Install ldap php dependencie === -RUN set -x \ - && buildDeps="libldap2-dev" \ - && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ - \ - && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ - && docker-php-ext-install ldap \ - \ - && apt-get purge -y ${buildDeps} \ - && rm -rf /var/lib/apt/lists/* - -#=== Install intl, soap opcache, and zip php dependencie === -RUN set -x \ - && buildDeps="libicu-dev zlib1g-dev libxml2-dev" \ - && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ - \ - && docker-php-ext-configure intl \ - && docker-php-ext-install intl \ - && docker-php-ext-install zip \ - && docker-php-ext-install soap \ - && docker-php-ext-install opcache \ - \ - && apt-get purge -y ${buildDeps} \ - && rm -rf /var/lib/apt/lists/* - -#=== Install mysqli php dependencie === -RUN set -x \ - && docker-php-ext-install mysqli - -#=== Install pgsql dependencie === -RUN set -ex \ - && buildDeps="libpq-dev" \ - && apt-get update && apt-get install -y $buildDeps \ - \ - && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ - && docker-php-ext-install pdo pdo_pgsql pgsql \ - \ - && apt-get purge -y ${buildDeps} \ - && rm -rf /var/lib/apt/lists/* - -#=== Apache vhost === -RUN { \ - echo ''; \ - echo 'DocumentRoot /var/www/html'; \ - echo; \ - echo ''; \ - echo '\tOptions -Indexes'; \ - echo '\tAllowOverride all'; \ - echo ''; \ - echo ''; \ - } | tee "$APACHE_CONFDIR/sites-available/app.conf" \ - && set -x \ - && a2ensite app \ - && a2dissite 000-default \ - && echo "ServerName localhost" >> $APACHE_CONFDIR/apache2.conf - -#=== Apache security === -RUN { \ - echo 'ServerTokens Prod'; \ - echo 'ServerSignature Off'; \ - echo 'TraceEnable Off'; \ - echo 'Header set X-Content-Type-Options: "nosniff"'; \ - echo 'Header set X-Frame-Options: "sameorigin"'; \ - } | tee $APACHE_CONFDIR/conf-available/security.conf \ - && set -x \ - && a2enconf security - -#=== php default === -ENV PMF_TIMEZONE="Europe/Berlin" \ - PMF_ENABLE_UPLOADS=On \ - PMF_MEMORY_LIMIT=64M \ - PMF_DISABLE_HTACCESS="" \ - PHP_LOG_ERRORS=On \ - PHP_ERROR_REPORTING=E_ALL - -#=== Add source code from previously built interstage === -COPY --from=yarn /app/phpmyfaq . - -#=== Ensure debug mode is disabled and do some other stuff over the code === -RUN set -x \ - && sed -ri ./src/Bootstrap.php \ - -e "s~define\('DEBUG', true\);~define\('DEBUG', false\);~" \ - && mv ./config ../saved-config - -#=== Set custom entrypoint === -COPY docker-entrypoint.sh /entrypoint -RUN chmod +x /entrypoint -ENTRYPOINT [ "/entrypoint" ] - -#=== Re-Set CMD as we changed the default entrypoint === -CMD [ "apache2-foreground" ] diff --git a/3.0/docker-entrypoint.sh b/3.0/docker-entrypoint.sh deleted file mode 100644 index 3d98313..0000000 --- a/3.0/docker-entrypoint.sh +++ /dev/null @@ -1,105 +0,0 @@ -#! /bin/sh - -# Exit on error -set -e - -#=== Set folder permissions === -folders="attachments data images config" - -mkdir -vp $folders - -{ - if [ -f "$APACHE_ENVVARS" ]; then - . "$APACHE_ENVVARS" - chown -R "$APACHE_RUN_USER:$APACHE_RUN_GROUP" $folders - else - chown -R www-data:www-data $folders - fi - chmod 775 $folders -} - -#=== Check config files === -if [ ! -e "./config" ]; then - echo >&2 'WARN: missing config folder' - echo >&2 ' Did you forget to -v some_config_folder:/var/www/html/config ?' -else - for _file in ../saved-config/*.php; do - [ ! -e ./config/$( basename $_file ) ] && cp -v $_file ./config/$( basename $_file ) - done -fi - -##=== Check database vars === -#=== DB host === -if [ -z "$PMF_DB_HOST" -a ! -e "./config/database.php" ]; then - echo >&2 'WARN: missing PMF_DB_HOST environment variable' - echo >&2 ' Did you forget to --link some_mysql_container:db ?' -else - #=== DB user and pass === - : ${PMF_DB_USER:=root} - if [ "$PMF_DB_USER" = 'root' ]; then - : ${PMF_DB_PASS:=$DB_ENV_MYSQL_ROOT_PASSWORD} - fi - - if [ -z "$PMF_DB_PASS" ]; then - echo >&2 'ERROR: missing required PMF_DB_PASS environment variable' - echo >&2 ' Did you forget to -e PMF_DB_PASS=... ?' - echo >&2 - echo >&2 ' (Also of interest might be PMF_DB_USER and PMF_DB_NAME.)' - exit 1 - #=== Setup database if needed === - elif [ 0 -eq 1 ]; then # TODO : Add something like: php setup/maintenance.php --vars... - { - echo " Date: Wed, 9 May 2018 14:27:05 +0200 Subject: [PATCH 2/5] remove config folder test --- docker-entrypoint.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index cc61a0a..7dec465 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -19,14 +19,9 @@ mkdir -vp $folders } #=== Check config files === -if [ ! -e "./config" ]; then - echo >&2 'WARN: missing config folder' - echo >&2 ' Did you forget to -v some_config_folder:/var/www/html/config ?' -else - for _file in ../saved-config/*.php; do - [ ! -e ./config/$( basename $_file ) ] && cp -v $_file ./config/$( basename $_file ) - done -fi +for _file in ../saved-config/*.php; do + [ ! -e ./config/$( basename $_file ) ] && cp -v $_file ./config/$( basename $_file ) +done if [ -f "$APACHE_ENVVARS" ]; then #=== Enable htaccess for search engine optimisations === From afb0acb570f0ef7d509ec76696054d10f6f38f83 Mon Sep 17 00:00:00 2001 From: Maghin Date: Wed, 9 May 2018 14:40:45 +0200 Subject: [PATCH 3/5] update version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c7ec7d..e3ed2fe 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This image uses the multi-stage feature from docker. It's the one available on d Available arguments to build a new image: -**PMF_BRANCH**: Specifie the Github branch to include in the release _(default: 3.0)_ +**PMF_BRANCH**: Specify the Github branch to include in the release _(default: 3.0)_ ## To run @@ -22,7 +22,7 @@ _Running using volumes:_ - **phpmyadmin**: a PHP tool to have a look on your database. _Running apache web server with PHP support:_ -- **phpmyfaq**: mounts the ressources folders in `/var/www/html/`. +- **phpmyfaq**: mounts the ressources folders in `./volumes`. Then services will be available at following addresses: From dbe2a2abfa6ee03895a1ccce5051e572fd26f45c Mon Sep 17 00:00:00 2001 From: Maghin Date: Sun, 17 Jun 2018 12:19:30 +0200 Subject: [PATCH 4/5] Fix upload issue --- Dockerfile | 4 +++- docker-compose.yml | 2 ++ docker-entrypoint.sh | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 73c8b09..02dda8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -135,7 +135,9 @@ ENV PMF_TIMEZONE="Europe/Berlin" \ PMF_MEMORY_LIMIT=64M \ PMF_DISABLE_HTACCESS="" \ PHP_LOG_ERRORS=On \ - PHP_ERROR_REPORTING=E_ALL + PHP_ERROR_REPORTING=E_ALL\ + PHP_POST_MAX_SIZE=64M \ + PHP_UPLOAD_MAX_FILESIZE=64M #=== Add source code from previously built interstage === COPY --from=yarn /app/phpmyfaq . diff --git a/docker-compose.yml b/docker-compose.yml index 431c70d..70098ea 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,6 +30,8 @@ services: - PMF_MEMORY_LIMIT="64M" - PHP_LOG_ERRORS="On" - PHP_ERROR_REPORTING="E_ALL" # Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT + - PHP_POST_MAX_SIZE="64M" + - PHP_UPLOAD_MAX_FILESIZE="64M" links: - mariadb:db - elasticsearch diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7dec465..0e4f20f 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -51,6 +51,8 @@ fi echo "date.timezone = $PMF_TIMEZONE" echo "memory_limit = $PMF_MEMORY_LIMIT" echo "file_upload = $PMF_ENABLE_UPLOADS" + echo "post_max_size = $PHP_POST_MAX_SIZE" + echo "upload_max_filesize = $PHP_UPLOAD_MAX_FILESIZE" } | tee $PHP_INI_DIR/conf.d/php.ini #=== Set recommanded opcache settings === From 00ae96488cc48e9ba557304aa1c8396a136b361e Mon Sep 17 00:00:00 2001 From: Maghin Date: Sun, 17 Jun 2018 12:25:20 +0200 Subject: [PATCH 5/5] add build doc --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e3ed2fe..3ad214e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,21 @@ This image uses the multi-stage feature from docker. It's the one available on d Available arguments to build a new image: -**PMF_BRANCH**: Specify the Github branch to include in the release _(default: 3.0)_ +**PMF_BRANCH**: Specify the Github branch to include in the release _(default: 2.9)_ + +To build an image containing the current code in the specified branch: + + # Example with the 2.9 branch + git clone https://github.com/phpMyFAQ/docker-hub.git && cd docker-hub + git checkout 2.9 + docker build -t phpmyfaq . + +To build a specific tag of the PMF repo: + + # Example with the 2.9.10 tag + git clone https://github.com/phpMyFAQ/docker-hub.git && cd docker-hub + git checkout 2.9 + docker build -t phpmyfaq:2.9.10 --build-arg PMF_BRANCH=2.9.10 . ## To run