$ tree
.
├── Dockerfile
└── index.html
0 directories, 2 files
$ sudo docker build -t myapache .
$ sudo docker run -dit –name myapp -p 8080:80 myapache
buildspec.yml
version: 0.2 env: variables: AWS_REGION_NAME: ap-northeast-1 ECR_REPOSITORY_NAME: hoge DOCKER_BUILDKIT: "1" phases: install: runtime-versions: docker: 19 pre_build: commands: - AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text) - aws ecr --region ap-northeast-1 get-login-password | docker login --username AWS --password-stdin https://${AWS_ACCOUNT_ID}.dkr.ecr.ap-northeast-1.amazonaws.com/hpscript - REPOSITORY_URI=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION_NAME}.amazonaws.com/${ECR_REPOSITORY_NAME} - IMAGE_TAG=$(echo ${CODEBUILD_RESOLVED_SOURCE_VERSION} | cut -c 1-7) build: commands: - docker image build -t ${REPOSITORY_URI}:${IMAGE_TAG} . post_build: commands: - docker image push ${REPOSITORY_URI}:${IMAGE_TAG}
### AWS CodeBuild
– Project configuration
Project name: test
Build Badge: Enable build badge
– Source
Source provider: AWS CodeCommit
Repository: 指定
Reference type: Branch
Branch: 指定
– Environment
Environment image: Managed image
Operationg system: Amazon Linux2
Runtime(s): Standard
Image: aws/codebuild/amazonlinux2-x86_64-standard:3.0
Image version: Always use the latest image for this runtime
Environment type: Linux
Privileged: on
Service Role: New service role
Additional configuration
Timeout: 1 Hour 0 Minutes
Queued timeout: 8 Hour 0 Minutes
Certificate: Do not install any certificate
Compute: 3 GB memory, 2 vCPUs
– Buildspec
Use a buildspec file
– Artifact
Type: No artifacts
– Log
CloudWatch logs: CloudWatch logs
OK ここまでは出来た。次はcode deploy, codepipelineか。