Skip to content

Instantly share code, notes, and snippets.

@likejazz
Last active Mar 19, 2020
Embed
What would you like to do?
declare TARGET="ec2-XXXX.ap-northeast-2.compute.amazonaws.com"
readonly VERSION=$(date '+%y.%m.%d') # Today's yy.mm.dd ubuntu version style.
readonly IMAGE_NAME=edith/edith-XXXX
readonly ECR_REGISTRY=09960362XXXX.dkr.ecr.ap-northeast-2.amazonaws.com/edith/edith-XXXX
readonly AWS_OTP=$(aws ecr get-login-password --region ap-northeast-2)
# Build
docker build -t ${IMAGE_NAME} .
# Push
echo "${AWS_OTP}" | docker login --username AWS --password-stdin ${ECR_REGISTRY}
docker tag edith/edith-XXXX:latest ${ECR_REGISTRY}:"${VERSION}"
docker push ${ECR_REGISTRY}:"${VERSION}"
# Deploy
ssh -i ~/.ssh/aws_skpark.pem ec2-user@${TARGET} "./update-docker.sh ${AWS_OTP}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment