tomoki312
@tomoki312

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

CircleCI OrbsでFargateにデプロイする時に500ERRORになる

解決したいこと

Laravelでポートフォリオ作成中です
CircleCI OrbsでFargateにデプロイする際に500ERRORが発生しました。
手動でデプロイする際には正常に動作します。
解決方法を教えてください

該当するソースコード

config.yml
version: 2.1
orbs:
  aws-ecr: circleci/aws-ecr@8.1
  aws-ecs: circleci/aws-ecs@3.2

executors:
  docker_build:
    machine:
      docker_layer_caching: true

workflows:
  build-and-deploy:
    jobs:
      - build
      - aws-ecr/build-and-push-image:
          name: "php"
          executor: docker_build
          registry-id: AWS_ECR_REGISTRY_ID
          region: "ap-northeast-1"
          repo: "php"
          tag: "${CIRCLE_SHA1}"
          path: ./
          dockerfile: ./docker/php/Dockerfile
          requires:
            - build
          filters:
            branches:
              only:
                - main

      - aws-ecr/build-and-push-image:
          name: "nginx"
          executor: docker_build
          registry-id: AWS_ECR_REGISTRY_ID
          region: "ap-northeast-1"
          repo: "nginx"
          tag: "${CIRCLE_SHA1}"
          path: ./
          dockerfile: ./docker/nginx/Dockerfile
          requires:
            - build
          filters:
            branches:
              only:
                - main
                
      - aws-ecs/deploy-service-update:
          family: "distributed_learn_task_definition"
          service-name: "distributed-learn-service"
          cluster: "distributed-learn-cluster"
          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}"
          requires:
            - php
            - nginx
          filters:
            branches:
              only:
                - main

nignx/Dockerfile
FROM nginx:1.20-alpine AS base
ENV TZ=Asia/Tokyo
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf

FROM base AS development
COPY ./docker/nginx/development/default.conf /etc/nginx/conf.d/default.conf

FROM base AS prod
COPY ./docker/nginx/prod/default.conf /etc/nginx/conf.d/default.conf
COPY ./src /var/www/html
EXPOSE 80
php/Dockerfile
FROM php:8.1-fpm-bullseye

WORKDIR /var/www/html

# timezone environment
ENV TZ=Asia/Tokyo \
  # locale
  LANG=ja_JP.UTF-8 \
  LANGUAGE=ja_JP:ja \
  LC_ALL=ja_JP.UTF-8 \
  # composer environment
  COMPOSER_ALLOW_SUPERUSER=1 \
  COMPOSER_HOME=/composer

COPY --from=composer:2.3 /usr/bin/composer /usr/bin/composer

RUN apt-get update \
  && apt-get -y install --no-install-recommends \
    locales \
    git \
    unzip \
    vim \
    libzip-dev \
    libicu-dev \
    libonig-dev \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/* \
  && locale-gen ja_JP.UTF-8 \
  && localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 \
  && docker-php-ext-install \
    intl \
    pdo_mysql \
    zip \
    bcmath \
  && composer config -g process-timeout 3600 \
  && composer config -g repos.packagist composer https://packagist.org

COPY ./src /var/www/html
COPY ./docker/php/php.ini /usr/local/etc/php/php.ini

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

自分で試したこと

nginx/Dockerfileでbaseをprodのみにしてpush。

0

1Answer

Your answer might help someone💌