반응형
혹시 그거 아시나요? Codebuild 같은 경우는 buildspec.yml 파일을 사용해서 빌드/ 테스트를 진행합니다. 그런데 이런 생각도 되죠? 어? 환경에서 운영 체제를 Linux 기반에 운영 체제를 사용하는데 Shell Scripting도 가능할까?
정답은? "네 가능합니다" 어떻게 작성해야하는지 아래 확인을 해주시면 됩니다.
https://lxstitch.tistory.com/65 < 이 분이 정말 잘 Shell script IF문에 대해서 설명이 너무 좋으시네용
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- |
if [[ -e Dockerfile ]]; then
docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
else
echo "No Dockerfile"
fi
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
중요한 점은 if 옆에 오는 대괄호는 [ (하나)가 아닌 [[ (두개) 여야합니다.
실행 결과
없다면?
반응형
'2022년 전에 정리한 문서들' 카테고리의 다른 글
Golang Command in Linux (0) | 2022.08.19 |
---|---|
Golang 기초 정리 (0) | 2022.08.19 |
Dockerfile 기본 문법, 옵션 정리 (0) | 2022.08.19 |
Docker Command (0) | 2022.08.19 |
Kinesis ERROR (0) | 2022.08.08 |