diff --git a/scripts/deploy.sh b/scripts/deploy.sh index cb2730b..d1fb5ba 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,9 +1,19 @@ #!/usr/bin/env sh set -e -ENV=${1:-test} +ENV=${1:-prod} MODE=${2:-no-build} ENVFILE="" if [ -f ".env.$ENV" ]; then ENVFILE="--env-file .env.$ENV"; fi +PLATFORM=${PLATFORM:-} +if [ -z "$PLATFORM" ]; then + ARCH=$(uname -m) + case "$ARCH" in + x86_64) PLATFORM="linux/amd64" ;; + aarch64) PLATFORM="linux/arm64" ;; + *) PLATFORM="linux/amd64" ;; + esac +fi +export PLATFORM case "$MODE" in no-build) APP_ENV=$ENV docker compose $ENVFILE up -d ;; diff --git a/scripts/deploy_image.sh b/scripts/deploy_image.sh index d430157..a5b4388 100644 --- a/scripts/deploy_image.sh +++ b/scripts/deploy_image.sh @@ -5,6 +5,14 @@ ENV=${1:-test} IMAGE=${2:-marketingsystemdatatool_msdt:latest} CMD=${3:-up} PLATFORM=${PLATFORM:-} +if [ -z "$PLATFORM" ]; then + ARCH=$(uname -m) + case "$ARCH" in + x86_64) PLATFORM="linux/amd64" ;; + aarch64) PLATFORM="linux/arm64" ;; + *) PLATFORM="linux/amd64" ;; + esac +fi ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd) @@ -19,6 +27,20 @@ case "$CMD" in docker rm -f msdt >/dev/null 2>&1 || true PLATFORM_FLAG="" if [ -n "$PLATFORM" ]; then PLATFORM_FLAG="--platform $PLATFORM"; fi + IMG_ARCH="" + if docker image inspect "$IMAGE" >/dev/null 2>&1; then + IMG_ARCH=$(docker image inspect "$IMAGE" --format '{{.Architecture}}' 2>/dev/null || echo "") + fi + if [ -n "$IMG_ARCH" ]; then + HOST_ARCH=$(uname -m) + case "$HOST_ARCH" in x86_64) HOST_ARCH="amd64" ;; aarch64) HOST_ARCH="arm64" ;; *) HOST_ARCH="amd64" ;; esac + if [ "$IMG_ARCH" != "$HOST_ARCH" ]; then + docker pull --platform "$PLATFORM" "$IMAGE" >/dev/null 2>&1 || true + PLATFORM_FLAG="--platform $PLATFORM" + fi + else + docker pull --platform "$PLATFORM" "$IMAGE" >/dev/null 2>&1 || true + fi docker run -d --name msdt $PLATFORM_FLAG \ -p 8077:8077 \ -e APP_ENV="$ENV" \ diff --git a/scripts/image.tar b/scripts/image.tar deleted file mode 100644 index c5db75d..0000000 Binary files a/scripts/image.tar and /dev/null differ