multica/src/gateway/scripts/build-and-push.sh
yushen 2ea7938444 Add Docker support for Gateway and SDK documentation
- Add Dockerfile and build script for Gateway containerization
- Add USAGE.md documenting SDK usage for Client/Agent implementations
- Move socket.io-client to production dependencies (required by SDK)
- Remove redundant timestamp field from RoutedMessage (UUID v7 contains timestamp)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 17:56:22 +08:00

33 lines
1,007 B
Bash
Executable file

#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
GATEWAY_DIR="$(dirname "$SCRIPT_DIR")"
PROJECT_ROOT="$(cd "$GATEWAY_DIR/../.." && pwd)"
REPO="085931705009.dkr.ecr.us-west-2.amazonaws.com/super-multica/gateway"
BRANCH="$(git symbolic-ref --short -q HEAD | tr '/' '-')"
IMAGE_TAG="$(date +%F_%H-%M-%S)-${BRANCH}-$(git rev-parse --short HEAD)"
IMAGE="$REPO:$IMAGE_TAG"
# Determine if sudo is needed for docker commands
if [[ "$(uname -s)" == "Linux" ]]; then
DOCKER_CMD="sudo docker"
else
DOCKER_CMD="docker"
fi
echo "Building image: $IMAGE"
echo "Using Dockerfile: $GATEWAY_DIR/Dockerfile"
echo "Build context: $PROJECT_ROOT"
# Login to ECR
aws ecr get-login-password --region us-west-2 | $DOCKER_CMD login --username AWS --password-stdin 085931705009.dkr.ecr.us-west-2.amazonaws.com
# Build from project root with gateway Dockerfile
$DOCKER_CMD build -f "$GATEWAY_DIR/Dockerfile" -t "$IMAGE" "$PROJECT_ROOT"
$DOCKER_CMD push "$IMAGE"
echo ""
echo "Successfully pushed: $IMAGE"