Skip to content

Instantly share code, notes, and snippets.

@likejazz
Last active March 19, 2020 04:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save likejazz/ba41d83fc94dbb75b982f4e37dc008b6 to your computer and use it in GitHub Desktop.
Save likejazz/ba41d83fc94dbb75b982f4e37dc008b6 to your computer and use it in GitHub Desktop.
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