Last active
February 15, 2022 13:00
-
-
Save choi-ys/9a09001e2a9ace049d3f752a0b830cf4 to your computer and use it in GitHub Desktop.
Application build 및 artifact upload를 위한 AWS Code Build의 설정 파일 buildspec.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: 0.2 | |
phases: | |
install: | |
runtime-versions: | |
java: corretto11 | |
pre_build: | |
commands: | |
- REGION=ap-northeast-2 | |
- REPOSITORY_URI=xxxxx.dkr.ecr.ap-northeast-2.amazonaws.com | |
- IMAGE_NAME=foobar | |
- IMAGE_TAG=latest | |
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) | |
- BUILD_TAG=${COMMIT_HASH:=latest} | |
- CONTAINER_NAME=foobar | |
- echo Logging in to Amazon ECR... | |
- aws --version | |
- aws ecr get-login-password --region $REGION | docker login -u AWS --password-stdin $REPOSITORY_URI | |
build: | |
commands: | |
- echo Building the Docker image... | |
- chmod +x gradlew | |
- ./gradlew bootBuildImage --imageName=$IMAGE_NAME | |
- docker tag $REPOSITORY_URI/$IMAGE_NAME:$IMAGE_TAG $REPOSITORY_URI/$IMAGE_NAME:$BUILD_TAG | |
post_build: | |
commands: | |
- echo Pushing the Docker images... | |
- docker push $REPOSITORY_URI/$IMAGE_NAME:$IMAGE_TAG | |
- docker push $REPOSITORY_URI/$IMAGE_NAME:$BUILD_TAG | |
- printf '[{"name":"%s","imageUri":"%s"}]' $CONTAINER_NAME $REPOSITORY_URI/$IMAGE_NAME:$BUILD_TAG > imagedefinitions.json | |
- cat imagedefinitions.json | |
artifacts: | |
files: | |
- imagedefinitions.json | |
# 참조 URL : https://jsonobject.tistory.com/539 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment