Closed myantyuWorld closed 1 year ago
aws-cliコンテナだと、Dockerがインストールされていないので、途中で失敗してた まずは、以下のサイト通りやってみて、docker-compose.yml, Dockerfileを"api"と見比べてみて、 何がダメなのかを切り分けたい
以下サイトのアプリは以下で管理
/Users/*********/Documents/Study/trash/django-copilot
https://www.endpointdev.com/blog/2022/06/how-to-deploy-containerized-django-app-with-aws-copilot/
できた。 ので、実装中の"api"のDockerfileを修正して実施 以下の警告が出ている MacBookPro.M2でコンテナ作っているから?
Note: Architecture type arm64 has been detected. We will set platform 'linux/x86_64' instead. If you'd rather build and run as architecture type arm64, please change the 'platform' field in your workload manifest to 'linux/arm64'.
✔ Wrote the manifest for service myantyu-api at copilot/myantyu-api/manifest.yml
Your manifest contains configurations like your container size and port (:8080).
- Update regional resources with stack set "myantyu-api-infrastructure" [succeeded] [0.0s]
All right, you're all set for local development.
Deploy: Yes
✔ Wrote the manifest for environment test at copilot/environments/test/manifest.yml
- Update regional resources with stack set "myantyu-api-infrastructure" [succeeded] [0.0s]
- Update regional resources with stack set "myantyu-api-infrastructure" [succeeded] [136.2s]
- Update resources in region "ap-northeast-1" [create complete] [137.0s]
- KMS key to encrypt pipeline artifacts between stages [create complete] [120.2s]
- ECR container image repository for "myantyu-api" [create complete] [0.0s]
- S3 Bucket to store local artifacts [create complete] [1.1s]
✔ Proposing infrastructure changes for the myantyu-api-test environment.
- Creating the infrastructure for the myantyu-api-test environment. [create complete] [110.1s]
- An IAM Role for AWS CloudFormation to manage resources [create complete] [47.8s]
- An IAM Role to describe resources in your environment [create complete] [49.5s]
✔ Provisioned bootstrap resources for environment test in region ap-northeast-1 under application myantyu-api.
✔ Provisioned bootstrap resources for environment test.
✔ Proposing infrastructure changes for the myantyu-api-test environment.
- Creating the infrastructure for the myantyu-api-test environment. [update complete] [78.1s]
- An ECS cluster to group your services [create complete] [2.0s]
- A security group to allow your containers to talk to each other [create complete] [0.0s]
- An Internet Gateway to connect to the public internet [create complete] [14.8s]
- Private subnet 1 for resources with no internet access [create complete] [4.5s]
- Private subnet 2 for resources with no internet access [create complete] [4.5s]
- A custom route table that directs network traffic for the public subnets [create complete] [10.0s]
- Public subnet 1 for resources that can access the internet [create complete] [4.5s]
- Public subnet 2 for resources that can access the internet [create complete] [4.5s]
- A private DNS namespace for discovering services within the environment [create complete] [45.3s]
- A Virtual Private Cloud to control networking of your AWS resources [create complete] [14.0s]
Building your container image: docker build -t 583492173965.dkr.ecr.ap-northeast-1.amazonaws.com/myantyu-api/myantyu-api --platform linux/x86_64 /Users/ohbay/Documents/Study/template-vue-frontend/api/django_api -f /Users/ohbay/Documents/Study/template-vue-frontend/api/django_api/Dockerfile
[+] Building 2.8s (18/18) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 971B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3 2.4s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> CACHED [ 1/13] FROM docker.io/library/python:3@sha256:1274a1fb3354baf78e80cc7485771175b506a4712e49e272765dceeb0528fad1 0.0s
=> => resolve docker.io/library/python:3@sha256:1274a1fb3354baf78e80cc7485771175b506a4712e49e272765dceeb0528fad1 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 2B 0.0s
=> CANCELED [ 2/13] RUN apt-get update 0.2s
=> CACHED [ 3/13] RUN apt-get -y install locales && localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 0.0s
=> CACHED [ 4/13] RUN apt-get install -y vim less 0.0s
=> CACHED [ 5/13] RUN pip install --upgrade pip 0.0s
=> CACHED [ 6/13] RUN pip install --upgrade setuptools 0.0s
=> CACHED [ 7/13] RUN pip install django 0.0s
=> CACHED [ 8/13] RUN pip install psycopg2 0.0s
=> CACHED [ 9/13] RUN pip install djangorestframework 0.0s
=> CACHED [10/13] RUN pip install django-filter 0.0s
=> CACHED [11/13] RUN pip install django-cors-headers 0.0s
=> CACHED [12/13] WORKDIR /app 0.0s
=> ERROR [13/13] COPY ./api/django_api /app/ 0.0s
------
> [13/13] COPY ./api/django_api /app/:
------
failed to compute cache key: failed to walk /var/lib/docker/tmp/buildkit-mount1658684941/api: lstat /var/lib/docker/tmp/buildkit-mount1658684941/api: no such file or directory
upload deploy resources for service myantyu-api: build and push image: build Dockerfile at /Users/ohbay/Documents/Study/template-vue-frontend/api/django_api/Dockerfile: building image: exit status 1
参考サイトのDjangoアプリを使用し、デプロイできた。 ただし、できたため問題と対応する課題が二つできた。
1。copilotでデプロイした時の料金は?(CloudFarmationやCloudWatch, ECR, ECSなどなど) 2。copilotでのアプリ最新化方法は? 3。作成済のAPIを、デプロイ検証できたアプリに移設する
以下のサイト
https://www.endpointdev.com/blog/2022/06/how-to-deploy-containerized-django-app-with-aws-copilot/
手順
手順(実際に試したもの)
参考にしたサイトは、djangoコマンドで、"startproject"するが、すでに作成済("api")のため この手順だと、dbのmigrateはしてない。 copilotでDBを作成?して、それをcopilotで作成するappと連携させる必要があるため
実行結果は以下の通り、 途中で失敗した
エラー内容
mini cheat sheet
https://github.com/myantyuWorld/template-vue-frontend/wiki#mini-cheat-sheet