Skip to content
Merged
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"dist",
"README.md",
"LICENSE",
"Dockerfile"
"Dockerfile",
"scripts/build-and-push-ecr.sh"
],
"scripts": {
"build": "tsup src/index.ts src/server.ts --format esm --dts --clean",
Expand Down
18 changes: 12 additions & 6 deletions scripts/build-and-push-ecr.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

AWS_REGION="${AWS_REGION:-${AGENTDISPATCH_AWS_REGION:-us-west-2}}"
AWS_REGION="${AWS_REGION:-${AWS_DEFAULT_REGION:-}}"
ECR_REPOSITORY="${ECR_REPOSITORY:-agentdispatch-worker-agentcore}"
IMAGE_TAG="${IMAGE_TAG:-latest}"
PLATFORM="${PLATFORM:-linux/arm64}"

if [[ -z "$AWS_REGION" ]]; then
echo "AWS_REGION or AWS_DEFAULT_REGION is required." >&2
exit 1
fi

if ! command -v aws >/dev/null 2>&1; then
echo "aws CLI is required." >&2
exit 1
Expand All @@ -16,8 +21,9 @@ if ! command -v docker >/dev/null 2>&1; then
exit 1
fi

ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"
IMAGE_URI="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${ECR_REPOSITORY}:${IMAGE_TAG}"
AWS_ACCOUNT_ID="$(aws sts get-caller-identity --query Account --output text)"
ECR_REGISTRY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"
IMAGE_URI="${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG}"

aws ecr describe-repositories \
--region "$AWS_REGION" \
Expand All @@ -26,12 +32,12 @@ aws ecr describe-repositories \
--region "$AWS_REGION" \
--repository-name "$ECR_REPOSITORY" >/dev/null

aws ecr get-login-password --region "$AWS_REGION" | \
docker login --username AWS --password-stdin "${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com"

npm ci
npm run build

aws ecr get-login-password --region "$AWS_REGION" | \
docker login --username AWS --password-stdin "$ECR_REGISTRY"

docker buildx build \
--platform "$PLATFORM" \
--tag "$IMAGE_URI" \
Expand Down
Loading