Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docker build & push scripts to package.json #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions deploy/push-ecr-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 -- This kind of conflicts (or at least muddies the water IMHO) with the "ownership" of creating repositories in the IAC here. Are we okay with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the TOA we have the repository creation, image build and push as part of the npm scripts, which I assume aims to easy build and deployment for devs, but we can bring it up tomorrow with the team and see how we want to go about it and how that can work with future CI-CD pipelines.

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"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading