From 8ec097d031e1e4bff6aa7c32157fb1934c31736f Mon Sep 17 00:00:00 2001 From: amandesai01 Date: Mon, 9 Sep 2024 11:31:55 +0530 Subject: [PATCH] chore(bin): script to publish docker images correctly --- bin/publish-docker.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 bin/publish-docker.sh diff --git a/bin/publish-docker.sh b/bin/publish-docker.sh new file mode 100644 index 0000000..1f9696b --- /dev/null +++ b/bin/publish-docker.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +source .env + +VERSION=$(npm pkg get version | tr -d \") + +if [ -z "$VERSION" ]; then + echo "Version not found in package.json" + return +fi + +docker build . -t profilecity/vidur:$VERSION -f infra/Dockerfile.prod + +# Publish to Docker registry +docker tag profilecity/vidur:$VERSION profilecity/vidur:latest +docker push profilecity/vidur:$VERSION +docker push profilecity/vidur:latest + +if [ -z "$ECR_HOST" ]; then + echo "ECR host not found " + return +fi +aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_HOST + +# Publish to ECR +docker tag profilecity/vidur:$VERSION $ECR_HOST/profilecity/vidur:$VERSION +docker tag profilecity/vidur:latest $ECR_HOST/profilecity/vidur:latest +docker push $ECR_HOST/profilecity/vidur:$VERSION +docker push $ECR_HOST/profilecity/vidur:latest