-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildspec.yml
48 lines (39 loc) · 1.57 KB
/
buildspec.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
version: 0.2
env:
git-credential-helper: yes
phases:
pre_build:
commands:
# Docker Hub へのログイン
- echo Logging in to Docker Hub...
- echo $DOCKER_HUB_PASSWORD | docker login -u $DOCKER_HUB_USERNAME --password-stdin
# 環境変数設定
- AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text)
- ECR_URL=${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
- URI=${ECR_URL}/${IMAGE_NAME}
# AWS ECR へのログイン
- echo Logging in to AWS ECR...
- aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin ${ECR_URL}
build:
commands:
- git checkout $(git describe --tags --abbrev=0)
- echo Building the Docker image...
- docker build -t ${URI}:${CODEBUILD_RESOLVED_SOURCE_VERSION} .
- echo Pushing the Docker images to container registry...
- docker push ${URI}:${CODEBUILD_RESOLVED_SOURCE_VERSION}
- echo Writing image definitions file...
- printf '{"ImageURI":"%s"}' ${URI}:${CODEBUILD_RESOLVED_SOURCE_VERSION} > imageDetail.json
- echo Build completed on `date`
artifacts:
files:
- appspec.yaml
- taskdef.json
- imageDetail.json
secondary-artifacts:
DefinitionArtifact:
files:
- appspec.yaml
- taskdef.json
ImageArtifact:
files:
- imageDetail.json