|
| 1 | +ARG BUILDPLATFORM=linux/amd64 |
| 2 | +ARG TARGETPLATFORM |
| 3 | +ARG ALPINE_VERSION=3.14 |
| 4 | +ARG PHP_VERSION=7.3-alpine${ALPINE_VERSION} |
| 5 | +ARG COMPOSER_VERSION=2.1 |
| 6 | +ARG SUPERVISORD_VERSION=v0.7.3 |
| 7 | + |
| 8 | +FROM --platform=${BUILDPLATFORM} composer:${COMPOSER_VERSION} AS build-composer |
| 9 | +FROM composer:${COMPOSER_VERSION} AS composer |
| 10 | +FROM qmcgaw/binpot:supervisord-${SUPERVISORD_VERSION} AS supervisord |
| 11 | + |
| 12 | +FROM --platform=${BUILDPLATFORM} php:${PHP_VERSION} AS vendor |
| 13 | +COPY --from=build-composer --chown=${UID}:${GID} /usr/bin/composer /usr/bin/composer |
| 14 | +RUN apk add --no-cache unzip |
| 15 | +WORKDIR /srv |
| 16 | +COPY artisan composer.json composer.lock ./ |
| 17 | +COPY database ./database |
| 18 | +RUN composer install --prefer-dist --no-scripts --no-dev --no-autoloader |
| 19 | +RUN composer dump-autoload --no-scripts --no-dev --optimize |
| 20 | + |
| 21 | +FROM --platform=${BUILDPLATFORM} vendor AS test |
| 22 | +COPY . . |
| 23 | +RUN mv .env.travis .env |
| 24 | +RUN composer install |
| 25 | +RUN php artisan key:generate |
| 26 | +ENTRYPOINT [ "/srv/vendor/bin/phpunit" ] |
| 27 | + |
| 28 | +FROM alpine:${ALPINE_VERSION} |
| 29 | + |
| 30 | +ARG UID=1000 |
| 31 | +ARG GID=1000 |
| 32 | + |
| 33 | +# Composer 2 |
| 34 | +COPY --from=composer --chown=${UID}:${GID} /usr/bin/composer /usr/bin/composer |
| 35 | +# Supervisord from https://github.com/ochinchina/supervisord |
| 36 | +COPY --from=supervisord --chown=${UID}:${GID} /bin /usr/local/bin/supervisord |
| 37 | + |
| 38 | +# Install PHP and PHP system dependencies |
| 39 | +RUN apk add --update --no-cache \ |
| 40 | + # PHP |
| 41 | + php7 \ |
| 42 | + # Composer dependencies |
| 43 | + php7-phar \ |
| 44 | + # PHP SQLite driver |
| 45 | + php7-pdo_sqlite php7-sqlite3 \ |
| 46 | + # PHP extensions |
| 47 | + php7-xml php7-gd php7-mbstring \ |
| 48 | + # Runtime dependencies |
| 49 | + php7-session php7-json php7-openssl \ |
| 50 | + # Nginx and PHP FPM to serve over HTTP |
| 51 | + php7-fpm nginx \ |
| 52 | + && \ |
| 53 | + # Clean up |
| 54 | + rm /etc/nginx/nginx.conf && \ |
| 55 | + # Fix ownership to ${UID}:${GID} |
| 56 | + chown -R ${UID}:${GID} /var/lib/nginx/ |
| 57 | + |
| 58 | +# PHP FPM configuration |
| 59 | +# Change username and ownership in php-fpm pool config |
| 60 | +RUN sed -i '/user = nobody/d' /etc/php7/php-fpm.d/www.conf && \ |
| 61 | + sed -i '/group = nobody/d' /etc/php7/php-fpm.d/www.conf && \ |
| 62 | + sed -i '/listen.owner/d' /etc/php7/php-fpm.d/www.conf && \ |
| 63 | + sed -i '/listen.group/d' /etc/php7/php-fpm.d/www.conf |
| 64 | +# Pre-create files with the correct permissions |
| 65 | +RUN mkdir /run/php && \ |
| 66 | + chown ${UID}:${GID} /run/php /var/log/php7 && \ |
| 67 | + chmod 700 /run/php /var/log/php7 |
| 68 | + |
| 69 | +# Nginx configuration |
| 70 | +EXPOSE 8000/tcp |
| 71 | +RUN touch /run/nginx/nginx.pid /var/lib/nginx/logs/error.log && \ |
| 72 | + chown ${UID}:${GID} /run/nginx/nginx.pid /var/lib/nginx/logs/error.log |
| 73 | +COPY --chown=${UID}:${GID} docker/nginx.conf /etc/nginx/nginx.conf |
| 74 | +RUN nginx -t |
| 75 | + |
| 76 | +# Supervisord configuration |
| 77 | +COPY --chown=${UID}:${GID} docker/supervisord.conf /etc/supervisor/supervisord.conf |
| 78 | + |
| 79 | +# Create end user directory |
| 80 | +RUN mkdir -p /2fauth && \ |
| 81 | + chown -R ${UID}:${GID} /2fauth && \ |
| 82 | + chmod 700 /2fauth |
| 83 | + |
| 84 | +# Create /srv internal directory |
| 85 | +WORKDIR /srv |
| 86 | +RUN chown -R ${UID}:${GID} /srv && \ |
| 87 | + chmod 700 /srv |
| 88 | + |
| 89 | +# Run without root |
| 90 | +USER ${UID}:${GID} |
| 91 | + |
| 92 | +# Dependencies |
| 93 | +COPY --from=vendor --chown=${UID}:${GID} /srv/vendor /srv/vendor |
| 94 | + |
| 95 | +# Copy the rest of the code |
| 96 | +COPY --chown=${UID}:${GID} . . |
| 97 | +# RUN composer dump-autoload --no-scripts --no-dev --optimize |
| 98 | + |
| 99 | +# Entrypoint |
| 100 | +ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] |
| 101 | +COPY --chown=${UID}:${GID} docker/entrypoint.sh /usr/local/bin/entrypoint.sh |
| 102 | +RUN chmod 500 /usr/local/bin/entrypoint.sh |
| 103 | + |
| 104 | +ENV \ |
| 105 | + # You can change the name of the app |
| 106 | + APP_NAME=2FAuth \ |
| 107 | + # You can leave this on "local". If you change it to production most console commands will ask for extra confirmation. |
| 108 | + # Never set it to "testing". |
| 109 | + APP_ENV=local \ |
| 110 | + # Set to true if you want to see debug information in error screens. |
| 111 | + APP_DEBUG=false \ |
| 112 | + # This should be your email address |
| 113 | + |
| 114 | + # The encryption key for our database and sessions. Keep this very secure. |
| 115 | + # If you generate a new one all existing data must be considered LOST. |
| 116 | + # Change it to a string of exactly 32 chars or use command `php artisan key:generate` to generate it |
| 117 | + APP_KEY=SomeRandomStringOf32CharsExactly \ |
| 118 | + # This variable must match your installation's external address but keep in mind that |
| 119 | + # it's only used on the command line as a fallback value. |
| 120 | + APP_URL=http://localhost \ |
| 121 | + # Turn this to true if you want your app to react like a demo. |
| 122 | + # The Demo mode reset the app content every hours and set a generic demo user. |
| 123 | + IS_DEMO_APP=false \ |
| 124 | + # The log channel defines where your log entries go to. |
| 125 | + # 'daily' is the default logging mode giving you 5 daily rotated log files in /storage/logs/. |
| 126 | + # Several other options exist. You can use 'single' for one big fat error log (not recommended). |
| 127 | + # Also available are 'syslog', 'errorlog' and 'stdout' which will log to the system itself. |
| 128 | + LOG_CHANNEL=daily \ |
| 129 | + # Log level. You can set this from least severe to most severe: |
| 130 | + # debug, info, notice, warning, error, critical, alert, emergency |
| 131 | + # If you set it to debug your logs will grow large, and fast. If you set it to emergency probably |
| 132 | + # nothing will get logged, ever. |
| 133 | + APP_LOG_LEVEL=notice \ |
| 134 | + # Database config & credentials |
| 135 | + # DB_CONNECTION can only be sqlite |
| 136 | + DB_CONNECTION=sqlite \ |
| 137 | + DB_DATABASE="/srv/database/database.sqlite" \ |
| 138 | + # If you're looking for performance improvements, you could install memcached. |
| 139 | + CACHE_DRIVER=file \ |
| 140 | + SESSION_DRIVER=file \ |
| 141 | + # Mail settings |
| 142 | + # Refer your email provider documentation to configure your mail settings |
| 143 | + # Set a value for every available setting to avoid issue |
| 144 | + MAIL_DRIVER=log \ |
| 145 | + MAIL_HOST=smtp.mailtrap.io \ |
| 146 | + MAIL_PORT=2525 \ |
| 147 | + |
| 148 | + MAIL_USERNAME=null \ |
| 149 | + MAIL_PASSWORD=null \ |
| 150 | + MAIL_ENCRYPTION=null \ |
| 151 | + MAIL_FROM_NAME=null \ |
| 152 | + MAIL_FROM_ADDRESS=null \ |
| 153 | + # Leave the following configuration vars as is. |
| 154 | + # Unless you like to tinker and know what you're doing. |
| 155 | + BROADCAST_DRIVER=log \ |
| 156 | + QUEUE_DRIVER=sync \ |
| 157 | + SESSION_LIFETIME=12 \ |
| 158 | + REDIS_HOST=127.0.0.1 \ |
| 159 | + REDIS_PASSWORD=null \ |
| 160 | + REDIS_PORT=6379 \ |
| 161 | + PUSHER_APP_ID= \ |
| 162 | + PUSHER_APP_KEY= \ |
| 163 | + PUSHER_APP_SECRET= \ |
| 164 | + PUSHER_APP_CLUSTER=mt1 \ |
| 165 | + MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" \ |
| 166 | + MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" \ |
| 167 | + MIX_ENV=local |
| 168 | + |
| 169 | +ARG VERSION=unknown |
| 170 | +ARG CREATED="an unknown date" |
| 171 | +ARG COMMIT=unknown |
| 172 | +ENV \ |
| 173 | + VERSION=${VERSION} \ |
| 174 | + CREATED=${CREATED} \ |
| 175 | + COMMIT=${COMMIT} |
| 176 | +LABEL \ |
| 177 | + org.opencontainers.image.authors="https://github.com/Bubka" \ |
| 178 | + org.opencontainers.image.version=$VERSION \ |
| 179 | + org.opencontainers.image.created=$CREATED \ |
| 180 | + org.opencontainers.image.revision=$COMMIT \ |
| 181 | + org.opencontainers.image.url="https://github.com/Bubka/2FAuth" \ |
| 182 | + org.opencontainers.image.documentation="https://hub.docker.com/r/2fauth/2fauth" \ |
| 183 | + org.opencontainers.image.source="https://github.com/Bubka/2FAuth" \ |
| 184 | + org.opencontainers.image.title="2fauth" \ |
| 185 | + org.opencontainers.image.description="A web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes" |
0 commit comments