Codeseys/composer-replication-framework
0
1#!/usr/bin/env bash2# Build + push the baked SageMaker RL image to this account's private ECR (F3 §3.2).3# One-time (Admin). The one-shot smoke does NOT need this — use4# python examples/gsm8k_grpo/run_sagemaker_launch.py --image dlc5# which runs on the stock DLC + source_dir with no local build. Use this script6# for the repeatable path (no per-job pip-install) and the DiLoCo N-replica7# executor (which passes ContainerEntrypoint and wants the framework baked in).8#9# NOTE: the DLC base is GPU/linux-amd64 (~15 GB). On an Apple-Silicon host you10# must cross-build: pass --platform linux/amd64 (set below). This is slow under11# emulation; prefer building on a linux/amd64 host or CodeBuild for real use.12set -euo pipefail13 14REGION="${REGION:-us-west-2}"15ACCOUNT="${ACCOUNT:-386931836011}"16REPO="${REPO:-composer-rl}"17TAG="${TAG:-smoke}"18DLC_ACCOUNT="763104351884"19 20REGISTRY="${ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com"21IMAGE="${REGISTRY}/${REPO}:${TAG}"22REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"23 24echo "[ecr] region=${REGION} image=${IMAGE}"25 26# 1. Ensure the ECR repo exists (idempotent).27aws ecr describe-repositories --repository-names "${REPO}" --region "${REGION}" >/dev/null 2>&1 \28 || aws ecr create-repository --repository-name "${REPO}" --region "${REGION}" >/dev/null29 30# 2. Log in to BOTH the DLC registry (to pull the base) and our own (to push).31aws ecr get-login-password --region "${REGION}" \32 | docker login --username AWS --password-stdin "${DLC_ACCOUNT}.dkr.ecr.${REGION}.amazonaws.com"33aws ecr get-login-password --region "${REGION}" \34 | docker login --username AWS --password-stdin "${REGISTRY}"35 36# 3. Build (cross-arch on Apple Silicon) + push.37docker build --platform linux/amd64 \38 -f "${REPO_ROOT}/docker/Dockerfile.sagemaker" \39 -t "${IMAGE}" "${REPO_ROOT}"40docker push "${IMAGE}"41 42echo "[ecr] pushed ${IMAGE}"43echo "[ecr] launch with: python examples/gsm8k_grpo/run_sagemaker_launch.py --image ${IMAGE}"44 