From 293798ab166b8d8cf335d60953d7a2e0b5950deb Mon Sep 17 00:00:00 2001 From: Daniel Trolezi Date: Sun, 6 Oct 2024 23:30:51 -0300 Subject: [PATCH] Run composer install when building docker for production --- Dockerfile | 5 +++++ docker/entrypoint.sh | 10 +--------- docker/supervisor/conf.d/{octane.dev => octane.local} | 2 +- .../conf.d/{octane.prod => octane.production} | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) rename docker/supervisor/conf.d/{octane.dev => octane.local} (90%) rename docker/supervisor/conf.d/{octane.prod => octane.production} (91%) diff --git a/Dockerfile b/Dockerfile index c7ff42e..ad01033 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,12 +8,17 @@ WORKDIR /var/www/gamewatch COPY . /var/www/gamewatch COPY ./docker/php "${PHP_INI_DIR}/conf.d/" COPY ./docker/supervisor /etc/supervisor/ +COPY ./docker/supervisor/conf.d/octane.${APP_ENV} /etc/supervisor/conf.d/octane.conf COPY ./docker/nginx/default.conf /etc/nginx/conf.d/ RUN if [ "$APP_ENV" = "local" ]; then \ apt-get update && apt-get install -y nano npm; \ fi +RUN if [ "$APP_ENV" = "production" ]; then \ + composer install --no-interaction --optimize-autoloader --no-dev; \ + fi + #RUN find /var/www/gamewatch -not -path "/var/www/gamewatch/vendor/*" -type f -exec chmod 644 {} \; \ # && find /var/www/gamewatch -type d -exec chmod 755 {} \; \ # && chown -R www-data:www-data /var/www/gamewatch \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 6fe6c26..c702eee 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -11,20 +11,12 @@ if [ ! -d "vendor" ] || [ -z "$(ls -A vendor)" ]; then npm install php artisan key:generate --ansi - php artisan migrate --seed - else - composer install --no-interaction --optimize-autoloader --no-dev + php artisan migrate --seed fi fi case "$RUN_MODE" in octane) - if [ "$APP_ENV" == "local" ]; then - cp /etc/supervisor/conf.d/octane.dev /etc/supervisor/conf.d/octane.conf - else - cp /etc/supervisor/conf.d/octane.prod /etc/supervisor/conf.d/octane.conf - fi - supervisord -c /etc/supervisor/supervisord.conf ;; notif) diff --git a/docker/supervisor/conf.d/octane.dev b/docker/supervisor/conf.d/octane.local similarity index 90% rename from docker/supervisor/conf.d/octane.dev rename to docker/supervisor/conf.d/octane.local index f6a6a71..90a30f5 100644 --- a/docker/supervisor/conf.d/octane.dev +++ b/docker/supervisor/conf.d/octane.local @@ -1,4 +1,4 @@ -[program:octane-dev] +[program:octane] command=php artisan octane:swoole --watch autostart=true autorestart=true diff --git a/docker/supervisor/conf.d/octane.prod b/docker/supervisor/conf.d/octane.production similarity index 91% rename from docker/supervisor/conf.d/octane.prod rename to docker/supervisor/conf.d/octane.production index b5cdbc5..92cb2fa 100644 --- a/docker/supervisor/conf.d/octane.prod +++ b/docker/supervisor/conf.d/octane.production @@ -1,4 +1,4 @@ -[program:octane-prod] +[program:octane] command=php artisan octane:swoole --workers=4 --task-workers=4 autostart=true autorestart=true