简体   繁体   中英

AWS | Laravel | ECS(G/B) | CodeDeploy unfinish

I'm using Laravel. I want to deploy it to ECS (B/G) to see how it works. In the development environment, Laravel is running. I was able to launch my Laravel project on EC2 using docker. I want to use Fargate for the first time and deploy to ECS!

Also, CodeBuild has completed successfully.

appspec.yml

version: 0.0 Resources:
  - TargetService:
      Type: AWS::ECS::Service
      Properties:
        TaskDefinition: "<TASK_DEFINITION>"
        LoadBalancerInfo:
          ContainerName: "nginx"
          ContainerPort: "80"

taskdef.json

{
  "taskRoleArn": "arn:aws:iam::**********:role/ecsTaskExecutionRole",
  "executionRoleArn": "arn:aws:iam::**********:role/ecsTaskExecutionRole",
  "containerDefinitions": [
    {
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/****-system",
          "awslogs-region": "******",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "entryPoint": [
        "sh",
        "-c"
      ],
      "command": [
        "php artisan config:cache && php artisan migrate && chmod -R 777 storage/ &&  chmod -R 777 bootstrap/cache/"
      ],
      "cpu": 0,
      "environment": [
        {
          "name": "APP_ENV",
          "value": "staging"
        }
      ],
      "workingDirectory": "/var/www/html",
      "image": "<IMAGE1_NAME>",
      "name": "php"
    },
    {
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/****-system",
          "awslogs-region": "****",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "portMappings": [
        {
          "hostPort": 80,
          "protocol": "tcp",
          "containerPort": 80
        }
      ],
      "environment": [
        {
          "name": "APP_ENV",
          "value": "staging"
        }
      ],
      "workingDirectory": "/var/www/html",
      "image": "**********.dkr.ecr.**********.amazonaws.com/**********-nginx:latest",
      "name": "nginx"
    }
  ],
  "placementConstraints": [],
  "memory": "2048",
  "family": "*****-system",
  "requiresCompatibilities": [
    "FARGATE"
  ],
  "networkMode": "awsvpc",
  "cpu": "1024",
  "volumes": []
}

CodeDeploy stopped at INSTALL, and there are no errors. As you can see in the capture, we can confirm that "<TASK_DEFINITION>" has been replaced. I'd like to know if there's any information I'm missing.

I'm not sure how to set environment variables such as ".env", so I'm thinking this might be the cause.

CodeDeploy Failed

Revision

Task Definitions

ECR

ECR nginx

ECR src(laravel)

If you want to change.env file to set env variable, you may use ssh connection to your webserver and run nano.env command at root folder, to write the file.

You can also modify the file using ftp connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM