|
2 | 2 |
|
3 | 3 | ARG PHP_VERSION=8.2 |
4 | 4 | ARG NODE_VERSION=18 |
5 | | -FROM fideloper/fly-laravel:${PHP_VERSION} as base |
| 5 | +FROM ubuntu:22.04 as base |
| 6 | +LABEL fly_launch_runtime="laravel" |
6 | 7 |
|
7 | 8 | # PHP_VERSION needs to be repeated here |
8 | 9 | # See https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact |
9 | 10 | ARG PHP_VERSION |
| 11 | +ENV DEBIAN_FRONTEND=noninteractive \ |
| 12 | + COMPOSER_ALLOW_SUPERUSER=1 \ |
| 13 | + COMPOSER_HOME=/composer \ |
| 14 | + COMPOSER_MAX_PARALLEL_HTTP=24 \ |
| 15 | + PHP_PM_MAX_CHILDREN=10 \ |
| 16 | + PHP_PM_START_SERVERS=3 \ |
| 17 | + PHP_MIN_SPARE_SERVERS=2 \ |
| 18 | + PHP_MAX_SPARE_SERVERS=4 \ |
| 19 | + PHP_DATE_TIMEZONE=UTC \ |
| 20 | + PHP_DISPLAY_ERRORS=Off \ |
| 21 | + PHP_ERROR_REPORTING=22527 \ |
| 22 | + PHP_MEMORY_LIMIT=256M \ |
| 23 | + PHP_MAX_EXECUTION_TIME=90 \ |
| 24 | + PHP_POST_MAX_SIZE=100M \ |
| 25 | + PHP_UPLOAD_MAX_FILE_SIZE=100M \ |
| 26 | + PHP_ALLOW_URL_FOPEN=Off |
10 | 27 |
|
11 | | -LABEL fly_launch_runtime="laravel" |
| 28 | +# Prepare base container: |
| 29 | +# 1. Install PHP, Composer |
| 30 | +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer |
| 31 | +COPY .fly/php/ondrej_ubuntu_php.gpg /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg |
| 32 | +ADD .fly/php/packages/${PHP_VERSION}.txt /tmp/php-packages.txt |
| 33 | + |
| 34 | +RUN apt-get update \ |
| 35 | + && apt-get install -y --no-install-recommends gnupg2 ca-certificates git-core curl zip unzip \ |
| 36 | + rsync vim-tiny htop sqlite3 nginx supervisor cron \ |
| 37 | + && ln -sf /usr/bin/vim.tiny /etc/alternatives/vim \ |
| 38 | + && ln -sf /etc/alternatives/vim /usr/bin/vim \ |
| 39 | + && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-ubuntu-php-focal.list \ |
| 40 | + && apt-get update \ |
| 41 | + && apt-get -y --no-install-recommends install $(cat /tmp/php-packages.txt) \ |
| 42 | + && ln -sf /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm \ |
| 43 | + && mkdir -p /var/www/html/public && echo "index" > /var/www/html/public/index.php \ |
| 44 | + && apt-get clean \ |
| 45 | + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* |
12 | 46 |
|
13 | | -# copy application code, skipping files based on .dockerignore |
| 47 | +# 2. Copy config files to proper locations |
| 48 | +COPY .fly/nginx/ /etc/nginx/ |
| 49 | +COPY .fly/fpm/ /etc/php/${PHP_VERSION}/fpm/ |
| 50 | +COPY .fly/supervisor/ /etc/supervisor/ |
| 51 | +COPY .fly/entrypoint.sh /entrypoint |
| 52 | +COPY .fly/start-nginx.sh /usr/local/bin/start-nginx |
| 53 | +RUN chmod 754 /usr/local/bin/start-nginx |
| 54 | + |
| 55 | +# 3. Copy application code, skipping files based on .dockerignore |
14 | 56 | COPY . /var/www/html |
| 57 | +WORKDIR /var/www/html |
15 | 58 |
|
| 59 | +# 4. Setup application dependencies |
16 | 60 | RUN composer install --optimize-autoloader --no-dev \ |
17 | 61 | && mkdir -p storage/logs \ |
18 | 62 | && php artisan optimize:clear \ |
|
36 | 80 | RUN php artisan icons:cache && php artisan filament:cache-components |
37 | 81 | @endif |
38 | 82 |
|
| 83 | + |
39 | 84 | @if($build_assets) |
40 | 85 | # Multi-stage build: Build static assets |
41 | 86 | # This allows us to not include Node within the final container |
|
86 | 131 | && chown -R www-data:www-data /var/www/html/public |
87 | 132 | @endif |
88 | 133 |
|
| 134 | +# 5. Setup Entrypoint |
89 | 135 | @if($frankenphp_binary) |
90 | 136 | @include('frankenphp.builder') |
91 | 137 | @else |
92 | 138 | EXPOSE 8080 |
93 | 139 | @endif |
| 140 | + |
| 141 | +ENTRYPOINT ["/entrypoint"] |
0 commit comments