|
| 1 | +# |
| 2 | +# This image uses 2 interstage and an php:7.1-apache final stage |
| 3 | +# |
| 4 | +# Interstages are: |
| 5 | +# - composer |
| 6 | +# - npm & yarn & grunt |
| 7 | +# |
| 8 | +# Final stage gets all that generated stuff and add it to the final image |
| 9 | +# |
| 10 | + |
| 11 | +############################ |
| 12 | +#=== composer interstage === |
| 13 | +############################ |
| 14 | +FROM composer:latest as composer |
| 15 | +WORKDIR /app |
| 16 | + |
| 17 | +#=== Get PMF source code === |
| 18 | +ARG PMF_BRANCH="3.0" |
| 19 | +RUN set -x \ |
| 20 | + && git clone \ |
| 21 | + --depth 1 \ |
| 22 | + -b $PMF_BRANCH \ |
| 23 | + https://github.com/thorsten/phpMyFAQ.git \ |
| 24 | + /app |
| 25 | + |
| 26 | +#=== Call composer === |
| 27 | +RUN set -x \ |
| 28 | + && composer install --no-dev |
| 29 | + |
| 30 | +######################## |
| 31 | +#=== yarn interstage === |
| 32 | +######################## |
| 33 | +FROM node:latest as yarn |
| 34 | +WORKDIR /app |
| 35 | + |
| 36 | +COPY --from=composer /app /app |
| 37 | + |
| 38 | +RUN set -x \ |
| 39 | + && npm install node-sass -g --unsafe-perm |
| 40 | + |
| 41 | +RUN set -x \ |
| 42 | + && yarn install \ |
| 43 | + && yarn build |
| 44 | + |
| 45 | +################################# |
| 46 | +#=== Final stage with payload === |
| 47 | +################################# |
| 48 | +FROM php:7.1-apache |
| 49 | + |
| 50 | +#=== Install gd php dependencie === |
| 51 | +RUN set -x \ |
| 52 | + && buildDeps="libpng-dev libjpeg-dev libfreetype6-dev" \ |
| 53 | + && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ |
| 54 | + \ |
| 55 | + && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ |
| 56 | + && docker-php-ext-install gd \ |
| 57 | + \ |
| 58 | + && apt-get purge -y ${buildDeps} \ |
| 59 | + && rm -rf /var/lib/apt/lists/* |
| 60 | + |
| 61 | +#=== Install ldap php dependencie === |
| 62 | +RUN set -x \ |
| 63 | + && buildDeps="libldap2-dev" \ |
| 64 | + && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ |
| 65 | + \ |
| 66 | + && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ |
| 67 | + && docker-php-ext-install ldap \ |
| 68 | + \ |
| 69 | + && apt-get purge -y ${buildDeps} \ |
| 70 | + && rm -rf /var/lib/apt/lists/* |
| 71 | + |
| 72 | +#=== Install intl, soap opcache, and zip php dependencie === |
| 73 | +RUN set -x \ |
| 74 | + && buildDeps="libicu-dev zlib1g-dev libxml2-dev" \ |
| 75 | + && apt-get update && apt-get install -y ${buildDeps} --no-install-recommends \ |
| 76 | + \ |
| 77 | + && docker-php-ext-configure intl \ |
| 78 | + && docker-php-ext-install intl \ |
| 79 | + && docker-php-ext-install zip \ |
| 80 | + && docker-php-ext-install soap \ |
| 81 | + && docker-php-ext-install opcache \ |
| 82 | + \ |
| 83 | + && apt-get purge -y ${buildDeps} \ |
| 84 | + && rm -rf /var/lib/apt/lists/* |
| 85 | + |
| 86 | +#=== Install mysqli php dependencie === |
| 87 | +RUN set -x \ |
| 88 | + && docker-php-ext-install mysqli |
| 89 | + |
| 90 | +#=== Install pgsql dependencie === |
| 91 | +RUN set -ex \ |
| 92 | + && buildDeps="libpq-dev" \ |
| 93 | + && apt-get update && apt-get install -y $buildDeps \ |
| 94 | + \ |
| 95 | + && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ |
| 96 | + && docker-php-ext-install pdo pdo_pgsql pgsql \ |
| 97 | + \ |
| 98 | + && apt-get purge -y ${buildDeps} \ |
| 99 | + && rm -rf /var/lib/apt/lists/* |
| 100 | + |
| 101 | +#=== php default === |
| 102 | +ENV PMF_TIMEZONE="Europe/Berlin" \ |
| 103 | + PMF_ENABLE_UPLOADS=On \ |
| 104 | + PMF_MEMORY_LIMIT=64M \ |
| 105 | + PMF_DISABLE_HTACCESS="" \ |
| 106 | + PHP_LOG_ERRORS=On \ |
| 107 | + PHP_ERROR_REPORTING=E_ALL |
| 108 | + |
| 109 | +#=== Add source code from previously built interstage === |
| 110 | +COPY --from=yarn /app/phpmyfaq . |
| 111 | + |
| 112 | +#=== Ensure debug mode is disabled === |
| 113 | +RUN set -x \ |
| 114 | + && sed -ri ./src/Bootstrap.php \ |
| 115 | + -e "s~define\('DEBUG', true\);~define\('DEBUG', false\);~" |
| 116 | + |
| 117 | +#=== Set custom entrypoint === |
| 118 | +COPY docker-entrypoint.sh /entrypoint |
| 119 | +RUN chmod +x /entrypoint |
| 120 | +ENTRYPOINT [ "/entrypoint" ] |
| 121 | + |
| 122 | +#=== Re-Set CMD as we changed the default entrypoint === |
| 123 | +CMD [ "apache2-foreground" ] |
0 commit comments