解決したいこと
Laravelでポートフォリオ作成中です
CircleCI OrbsでFargateにデプロイする際に500ERRORが発生しました。
手動でデプロイする際には正常に動作します。
解決方法を教えてください
エラーコード
該当するソースコード
yaml:config.yml
1version: 2.1 2orbs: 3 aws-ecr: circleci/aws-ecr@8.1 4 aws-ecs: circleci/aws-ecs@3.2 5 6executors: 7 docker_build: 8 machine: 9 docker_layer_caching: true 10 11workflows: 12 build-and-deploy: 13 jobs: 14 - build 15 - aws-ecr/build-and-push-image: 16 name: "php" 17 executor: docker_build 18 registry-id: AWS_ECR_REGISTRY_ID 19 region: "ap-northeast-1" 20 repo: "php" 21 tag: "${CIRCLE_SHA1}" 22 path: ./ 23 dockerfile: ./docker/php/Dockerfile 24 requires: 25 - build 26 filters: 27 branches: 28 only: 29 - main 30 31 - aws-ecr/build-and-push-image: 32 name: "nginx" 33 executor: docker_build 34 registry-id: AWS_ECR_REGISTRY_ID 35 region: "ap-northeast-1" 36 repo: "nginx" 37 tag: "${CIRCLE_SHA1}" 38 path: ./ 39 dockerfile: ./docker/nginx/Dockerfile 40 requires: 41 - build 42 filters: 43 branches: 44 only: 45 - main 46 47 - aws-ecs/deploy-service-update: 48 family: "distributed_learn_task_definition" 49 service-name: "distributed-learn-service" 50 cluster: "distributed-learn-cluster" 51 container-image-name-updates: "container=php,image-and-tag=${AWS_ECR_ACCOUNT_URL}/php:${CIRCLE_SHA1},container=nginx,image-and-tag=${AWS_ECR_ACCOUNT_URL}/nginx:${CIRCLE_SHA1}" 52 requires: 53 - php 54 - nginx 55 filters: 56 branches: 57 only: 58 - main 59
Dockerfile:nignx/Dockerfile
1FROM nginx:1.20-alpine AS base 2ENV TZ=Asia/Tokyo 3COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf 4 5FROM base AS development 6COPY ./docker/nginx/development/default.conf /etc/nginx/conf.d/default.conf 7 8FROM base AS prod 9COPY ./docker/nginx/prod/default.conf /etc/nginx/conf.d/default.conf 10COPY ./src /var/www/html 11EXPOSE 80
Dockerfile:php/Dockerfile
1FROM php:8.1-fpm-bullseye 2 3WORKDIR /var/www/html 4 5# timezone environment 6ENV TZ=Asia/Tokyo \ 7 # locale 8 LANG=ja_JP.UTF-8 \ 9 LANGUAGE=ja_JP:ja \ 10 LC_ALL=ja_JP.UTF-8 \ 11 # composer environment 12 COMPOSER_ALLOW_SUPERUSER=1 \ 13 COMPOSER_HOME=/composer 14 15COPY --from=composer:2.3 /usr/bin/composer /usr/bin/composer 16 17RUN apt-get update \ 18 && apt-get -y install --no-install-recommends \ 19 locales \ 20 git \ 21 unzip \ 22 vim \ 23 libzip-dev \ 24 libicu-dev \ 25 libonig-dev \ 26 && apt-get clean \ 27 && rm -rf /var/lib/apt/lists/* \ 28 && locale-gen ja_JP.UTF-8 \ 29 && localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 \ 30 && docker-php-ext-install \ 31 intl \ 32 pdo_mysql \ 33 zip \ 34 bcmath \ 35 && composer config -g process-timeout 3600 \ 36 && composer config -g repos.packagist composer https://packagist.org 37 38COPY ./src /var/www/html 39COPY ./docker/php/php.ini /usr/local/etc/php/php.ini 40 41RUN composer install -q -n --no-ansi --no-dev --no-scripts --no-progress --prefer-dist \ 42 && composer dump-autoload \ 43 && chown -R www-data:www-data ./ \ 44 && chmod -R 777 storage bootstrap/cache \ 45 && php artisan optimize:clear \ 46 && php artisan optimize \ 47 && php artisan cache:clear \ 48 && php artisan config:clear \ 49 && php artisan route:clear \ 50 && php artisan view:clear 51
ログ
nginxビルドログ
#7 [base 2/2] COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf #7 DONE 0.1s #8 [prod 1/2] COPY ./docker/nginx/prod/default.conf /etc/nginx/conf.d/default.conf #8 DONE 0.0s #9 [prod 2/2] COPY ./src /var/www/html #9 DONE 0.0s #10 exporting to image #10 exporting layers #10 exporting layers 0.2s done #10 exporting manifest sha256:a9f4ce17afe8f7798d12099cd21c87c1266950d418e1c181518f24ba49b4cba9 done #10 exporting config sha256:8960dc5041bcb59397535b260577d448fdb89f47dfa1e5638ba8d99e474dd65f done #10 pushing layers
phpビルドログ
#14 [stage-0 7/7] RUN composer install -q -n --no-ansi --no-dev --no-scripts --no-progress --prefer-dist && composer dump-autoload && chown -R www-data:www-data ./ && chmod -R 777 storage bootstrap/cache && php artisan optimize:clear && php artisan optimize && php artisan cache:clear && php artisan config:clear && php artisan route:clear && php artisan view:clear #14 2.780 Generating optimized autoload files #14 3.574 > Illuminate\Foundation\ComposerScripts::postAutoloadDump #14 3.583 > @php artisan package:discover --ansi #14 3.670 Discovered Package: fruitcake/laravel-cors #14 3.670 Discovered Package: laravel/sanctum #14 3.670 Discovered Package: laravel/socialite #14 3.670 Discovered Package: laravel/tinker #14 3.670 Discovered Package: nesbot/carbon #14 3.670 Package manifest generated successfully. #14 3.675 Generated optimized autoload files containing 3393 classes #14 4.217 Cached events cleared! #14 4.218 Compiled views cleared! #14 4.218 Application cache cleared! #14 4.219 Route cache cleared! #14 4.219 Configuration cache cleared! #14 4.219 Compiled services and packages files removed! #14 4.219 Caches cleared successfully! #14 4.305 Configuration cache cleared! #14 4.309 Configuration cached successfully! #14 4.309 Route cache cleared! #14 4.316 Routes cached successfully! #14 4.316 Files cached successfully! #14 4.392 Application cache cleared! #14 4.468 Configuration cache cleared! #14 4.546 Route cache cleared! #14 4.629 Compiled views cleared! #14 DONE 4.7s
自分で試したこと
nginx/Dockerfileでbaseをprodのみにしてpush。
Orbsではなく、下のURLの方法を参考にaws/cliを使いbuld、pushをしてみましたが、上手くいきませんでした。
https://zenn.dev/takamin55/articles/6900fa8b2ac21c
APP_DEBUGをtrueにすると下記の内容が出力されました。
npm install & npm run prodが必要であるため、nginxのDockerfileに下記のコードを追加しましたが、同様のエラーが発生します。
Dockerfile
1WORKDIR /var/www/html 2RUN apt update \ 3 && apt install -y nodejs npm \ 4 && npm install \ 5 && npm run prod 6 7EXPOSE 80
回答1件
あなたの回答
tips
プレビュー