Search

CICD Script

새 바이너리 제공 시 Downloads 경로에 app 폴더에 복사 후 아래의 명령어 진행
app 폴더 미리 생성해두기
$BUCKET_NAME = (aws s3api list-buckets --query "Buckets[].Name" --output text) -split "`t" | Where-Object { $_ -match '^apdev-cloud-bucket-[a-zA-Z0-9]{4}$' } aws s3 cp ./app s3://$BUCKET_NAME/app --recursive
PowerShell
복사
아래부터는 CloudShell 에서 진행
BUCKET_NAME=$(aws s3api list-buckets --query "Buckets[].Name" --output text | tr '\t' '\n' | grep -E '^apdev-cloud-bucket-[a-zA-Z0-9]{4}$') mkdir -p app aws s3 cp s3://$BUCKET_NAME/app ./app --recursive
Shell
복사
Dockerfile
cat << 'EOF' > app/userv2/Dockerfile FROM alpine:latest WORKDIR /app RUN apk add libc6-compat --no-cache RUN apk add curl tcpdump ngrep --no-cache COPY userv2 . RUN chmod +x userv2 CMD "./userv2" EOF cat << 'EOF' > app/stressv2/Dockerfile FROM alpine:latest WORKDIR /app RUN apk add libc6-compat --no-cache RUN apk add curl tcpdump ngrep --no-cache COPY stressv2 . RUN chmod +x stressv2 CMD "./stressv2" EOF cat << 'EOF' > app/productv2/Dockerfile FROM alpine:latest WORKDIR /app RUN apk add libc6-compat --no-cache RUN apk add curl tcpdump ngrep --no-cache COPY productv2 . RUN chmod +x productv2 CMD "./productv2" EOF
Shell
복사
mv app/userv2/user* app/userv2/userv2 mv app/stressv2/stress* app/stressv2/stressv2 mv app/productv2/product* app/productv2/productv2
Shell
복사
mv app/userv2/user_1.0.1 app/userv2/userv2 mv app/stressv2/stress_1.0.1 app/stressv2/stressv2 mv app/productv2/product_1.0.1 app/productv2/productv2
Shell
복사
cd app ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) REGION_CODE=$(aws configure set region ap-northeast-2 && aws configure get region) aws ecr get-login-password --region $REGION_CODE | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com docker build -t $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/user:v1.0.1 ./userv2/ docker push $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/user:v1.0.1
Shell
복사
cd app ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) REGION_CODE=$(aws configure set region ap-northeast-2 && aws configure get region) aws ecr get-login-password --region $REGION_CODE | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com docker build -t $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/stress:v1.0.1 ./stressv2/ docker push $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/stress:v1.0.1
Shell
복사
cd app ACCOUNT_ID=$(aws sts get-caller-identity --query "Account" --output text) REGION_CODE=$(aws configure set region ap-northeast-2 && aws configure get region) aws ecr get-login-password --region $REGION_CODE | docker login --username AWS --password-stdin $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com docker build -t $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/product:v1.0.1 ./productv2/ docker push $ACCOUNT_ID.dkr.ecr.$REGION_CODE.amazonaws.com/product:v1.0.1
Shell
복사
ECS Console 가서 Task Definition Image Version Update 후 새 배포 진행