diff --git a/deploy/push-ecr-image.sh b/deploy/push-ecr-image.sh index edfcdf2..64c196f 100755 --- a/deploy/push-ecr-image.sh +++ b/deploy/push-ecr-image.sh @@ -2,7 +2,7 @@ set -e -AWS_REGION=$(aws configure get region || echo "$AWS_REGION" || echo "$AWS_DEFAULT_REGION") +AWS_REGION=$(echo "$AWS_REGION" || aws configure get region || echo "$AWS_DEFAULT_REGION") if [ -z "$AWS_REGION" ]; then echo "Could not determine current AWS region." @@ -13,9 +13,12 @@ AWS_ACCOUNT=$(aws sts get-caller-identity --query Account --output text) DOCKER_TAG="$(date +%Y%m%d)-$(git rev-parse --short=8 HEAD)" DOCKER_IMAGE=$AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/setup-app:$DOCKER_TAG +DOCKER_IMAGE_LATEST=$AWS_ACCOUNT.dkr.ecr.$AWS_REGION.amazonaws.com/setup-app:latest aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$AWS_ACCOUNT".dkr.ecr."$AWS_REGION".amazonaws.com -docker build -t "$DOCKER_IMAGE" . +aws ecr describe-repositories --repository-names setup-app --profile $AWS_PROFILE --region $AWS_REGION || aws ecr create-repository --repository-name setup-app --profile "$AWS_PROFILE" --region "$AWS_REGION" +docker build --platform=linux/amd64 -t "$DOCKER_IMAGE" -t "$DOCKER_IMAGE_LATEST" . docker push "$DOCKER_IMAGE" +docker push "$DOCKER_IMAGE_LATEST" echo "Pushed image $DOCKER_IMAGE" diff --git a/package.json b/package.json index 29c63a7..67295a7 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "typecheck": "tsc --noEmit", "checks": "run-p -c typecheck lint", "test:unit": "vitest", - "test": "run-p -c test:*" + "test": "run-p -c test:*", + "deploy:ecr": "./deploy/push-ecr-image.sh" }, "author": "Nathan Stitt", "license": "AGPL-3.0-or-later",