From 46aa6e3cde407ec41da0c2e4fa0239caa7b33f0d Mon Sep 17 00:00:00 2001 From: Kathryn Anne S Tan Date: Mon, 22 Jul 2024 00:18:26 +0300 Subject: [PATCH] Include test result for Dockerfile generated for laravel 10 using octane roadrunner --- .../Feature/Supported/10_octane_rr/Dockerfile | 54 +++++++++++++++++-- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Supported/10_octane_rr/Dockerfile b/tests/Feature/Supported/10_octane_rr/Dockerfile index 81bbe22..1995b3f 100644 --- a/tests/Feature/Supported/10_octane_rr/Dockerfile +++ b/tests/Feature/Supported/10_octane_rr/Dockerfile @@ -2,17 +2,61 @@ ARG PHP_VERSION=8.2 ARG NODE_VERSION=18 -FROM fideloper/fly-laravel:${PHP_VERSION} as base +FROM ubuntu:22.04 as base +LABEL fly_launch_runtime="laravel" # PHP_VERSION needs to be repeated here # See https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact ARG PHP_VERSION +ENV DEBIAN_FRONTEND=noninteractive \ + COMPOSER_ALLOW_SUPERUSER=1 \ + COMPOSER_HOME=/composer \ + COMPOSER_MAX_PARALLEL_HTTP=24 \ + PHP_PM_MAX_CHILDREN=10 \ + PHP_PM_START_SERVERS=3 \ + PHP_MIN_SPARE_SERVERS=2 \ + PHP_MAX_SPARE_SERVERS=4 \ + PHP_DATE_TIMEZONE=UTC \ + PHP_DISPLAY_ERRORS=Off \ + PHP_ERROR_REPORTING=22527 \ + PHP_MEMORY_LIMIT=256M \ + PHP_MAX_EXECUTION_TIME=90 \ + PHP_POST_MAX_SIZE=100M \ + PHP_UPLOAD_MAX_FILE_SIZE=100M \ + PHP_ALLOW_URL_FOPEN=Off -LABEL fly_launch_runtime="laravel" +# Prepare base container: +# 1. Install PHP, Composer +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer +COPY .fly/php/ondrej_ubuntu_php.gpg /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg +ADD .fly/php/packages/${PHP_VERSION}.txt /tmp/php-packages.txt + +RUN apt-get update \ + && apt-get install -y --no-install-recommends gnupg2 ca-certificates git-core curl zip unzip \ + rsync vim-tiny htop sqlite3 nginx supervisor cron \ + && ln -sf /usr/bin/vim.tiny /etc/alternatives/vim \ + && ln -sf /etc/alternatives/vim /usr/bin/vim \ + && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-ubuntu-php-focal.list \ + && apt-get update \ + && apt-get -y --no-install-recommends install $(cat /tmp/php-packages.txt) \ + && ln -sf /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm \ + && mkdir -p /var/www/html/public && echo "index" > /var/www/html/public/index.php \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* -# copy application code, skipping files based on .dockerignore +# 2. Copy config files to proper locations +COPY .fly/nginx/ /etc/nginx/ +COPY .fly/fpm/ /etc/php/${PHP_VERSION}/fpm/ +COPY .fly/supervisor/ /etc/supervisor/ +COPY .fly/entrypoint.sh /entrypoint +COPY .fly/start-nginx.sh /usr/local/bin/start-nginx +RUN chmod 754 /usr/local/bin/start-nginx + +# 3. Copy application code, skipping files based on .dockerignore COPY . /var/www/html +WORKDIR /var/www/html +# 4. Setup application dependencies RUN composer install --optimize-autoloader --no-dev \ && mkdir -p storage/logs \ && php artisan optimize:clear \ @@ -29,6 +73,7 @@ RUN rm -rf /etc/supervisor/conf.d/fpm.conf; \ ln -sf /etc/nginx/sites-available/default-octane /etc/nginx/sites-enabled/default; + # Multi-stage build: Build static assets # This allows us to not include Node within the final container FROM node:${NODE_VERSION} as node_modules_go_brrr @@ -77,4 +122,7 @@ RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ \ && rm -rf /var/www/html/public-npm \ && chown -R www-data:www-data /var/www/html/public +# 5. Setup Entrypoint EXPOSE 8080 + +ENTRYPOINT ["/entrypoint"]