Skip to content

Commit b2b6cc5

Browse files
eldiosclaude
andauthored
Fix deploy-validator script to use remote Docker images by default (#4583)
## Summary This PR updates the `deploy-validator.sh` script and Docker Compose configuration to use pre-built Docker images from the official registry by default, instead of building locally. ## Problem Previously, the default `LINERA_IMAGE` in the script was just `linera`, which assumed a locally built image. This caused issues when validators tried to deploy without explicitly building the image first. ## Solution ### Changes Made: 1. **`scripts/deploy-validator.sh`**: - Changed default behavior to use remote images from `us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera` - Added `--local-build` flag for explicitly building Docker images locally - Made `--remote-image` flag deprecated (remote is now the default) - Updated image tag logic: uses `latest` for main branch, `{branch}_release` for other branches - Updated help text and examples to reflect the new behavior 2. **`docker/docker-compose.yml`**: - Updated default `LINERA_IMAGE` from `linera` to `us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera:latest` - Applied to all services using the Linera image (proxy, shard, shard-init) ## Impact - **Improved UX**: Validators can now deploy without building images locally - **Faster deployments**: No need to wait for local builds (which can take several minutes) - **Consistency**: All validators use the same official images by default - **Backwards compatible**: Users can still build locally using `--local-build` ## Testing The script has been tested with: - Dry run mode to verify image selection logic - Syntax validation with `bash -n` - Help output verification ## Related PR Documentation updates: linera-io/linera-documentation#241 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 41f8794 commit b2b6cc5

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

docker/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ services:
4646
condition: service_completed_successfully
4747

4848
proxy:
49-
image: "${LINERA_IMAGE:-linera}"
49+
image: "${LINERA_IMAGE:-us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera:latest}"
5050
container_name: proxy
5151
ports:
5252
- "19100:19100"
@@ -60,7 +60,7 @@ services:
6060
condition: service_completed_successfully
6161

6262
shard:
63-
image: "${LINERA_IMAGE:-linera}"
63+
image: "${LINERA_IMAGE:-us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera:latest}"
6464
deploy:
6565
replicas: 4
6666
command: ["./compose-server-entrypoint.sh", "scylladb:tcp:scylla:9042", "1"]
@@ -73,7 +73,7 @@ services:
7373
condition: service_completed_successfully
7474

7575
shard-init:
76-
image: "${LINERA_IMAGE:-linera}"
76+
image: "${LINERA_IMAGE:-us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera:latest}"
7777
container_name: shard-init
7878
command: ["./compose-server-init.sh", "scylladb:tcp:scylla:9042", "1"]
7979
volumes:

scripts/deploy-validator.sh

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
# <email> - Email address for ACME/Let's Encrypt certificates (required)
1212
#
1313
# Options:
14-
# --remote-image - Use remote Docker image instead of building locally
14+
# --local-build - Build Docker image locally instead of using registry image
15+
# --remote-image - Explicitly use remote Docker image from registry (deprecated, now default)
1516
# --skip-genesis - Skip downloading genesis configuration
1617
# --force-genesis - Force re-download of genesis configuration
1718
# --custom-tag TAG - Use custom image tag (for testing, no _release suffix)
@@ -120,7 +121,8 @@ ARGUMENTS:
120121
<email> Email address for ACME/Let's Encrypt certificates (required)
121122
122123
OPTIONS:
123-
--remote-image Use remote Docker image instead of building locally
124+
--local-build Build Docker image locally instead of using registry image
125+
--remote-image Explicitly use remote Docker image from registry (deprecated, now default)
124126
--skip-genesis Skip downloading genesis configuration
125127
--force-genesis Force re-download of genesis configuration even if it exists
126128
--custom-tag TAG Use custom image tag (for testing, no _release suffix)
@@ -171,20 +173,20 @@ ENVIRONMENT VARIABLES:
171173
Default: 4G
172174
173175
EXAMPLES:
174-
# Deploy using local build
176+
# Deploy using remote image (default behavior)
175177
$(basename "$0") validator.example.com [email protected]
176178
177-
# Deploy using remote image with default tag (<branch>_release)
178-
$(basename "$0") validator.example.com [email protected] --remote-image
179+
# Deploy using local build
180+
$(basename "$0") validator.example.com [email protected] --local-build
179181
180182
# Deploy with custom tag for testing (no _release suffix)
181-
$(basename "$0") validator.example.com [email protected] --remote-image --custom-tag devnet_2025_08_21
183+
$(basename "$0") validator.example.com [email protected] --custom-tag devnet_2025_08_21
182184
183185
# Deploy with fully custom image
184186
LINERA_IMAGE=my-registry/my-image:my-tag $(basename "$0") validator.example.com [email protected]
185187
186188
# Deploy with custom registry and image name
187-
DOCKER_REGISTRY=gcr.io/my-project IMAGE_NAME=custom-linera $(basename "$0") validator.example.com [email protected] --remote-image
189+
DOCKER_REGISTRY=gcr.io/my-project IMAGE_NAME=custom-linera $(basename "$0") validator.example.com [email protected]
188190
189191
# Deploy with custom configuration
190192
NUM_SHARDS=8 $(basename "$0") validator.example.com [email protected]
@@ -203,11 +205,11 @@ EXAMPLES:
203205
204206
# Deploy with custom genesis bucket and path
205207
GENESIS_BUCKET=https://storage.googleapis.com/my-bucket GENESIS_PATH_PREFIX=my-deployment \
206-
$(basename "$0") validator.example.com [email protected] --remote-image
208+
$(basename "$0") validator.example.com [email protected]
207209
208210
# Deploy with direct genesis URL override
209211
GENESIS_URL=https://storage.googleapis.com/linera-io-dev-public/testnet-babbage/genesis.json \
210-
$(basename "$0") validator.example.com [email protected] --remote-image
212+
$(basename "$0") validator.example.com [email protected]
211213
212214
EOF
213215
}
@@ -747,6 +749,7 @@ main() {
747749
# Parse command line arguments
748750
local host=""
749751
local email=""
752+
local use_local_build=0
750753
local use_remote_image=0
751754
local skip_genesis=0
752755
local force_genesis=0
@@ -762,7 +765,12 @@ main() {
762765
usage
763766
exit 0
764767
;;
768+
--local-build)
769+
use_local_build=1
770+
shift
771+
;;
765772
--remote-image)
773+
# Deprecated option, remote is now default
766774
use_remote_image=1
767775
shift
768776
;;
@@ -936,7 +944,14 @@ main() {
936944
if [ -n "${LINERA_IMAGE:-}" ]; then
937945
# User provided complete image path, use as-is
938946
log INFO "Using user-specified Docker image: ${LINERA_IMAGE}"
939-
elif [ ${use_remote_image} -eq 1 ]; then
947+
elif [ ${use_local_build} -eq 1 ]; then
948+
# Local build explicitly requested
949+
export LINERA_IMAGE="${LINERA_IMAGE:-linera}"
950+
if ! build_local_image "${git_commit}" "${LINERA_IMAGE}"; then
951+
log ERROR "Failed to build local Docker image"
952+
exit 1
953+
fi
954+
else
940955
# Construct image path from components
941956
local docker_registry="${DOCKER_REGISTRY:-$DEFAULT_DOCKER_REGISTRY}"
942957
local image_name="${IMAGE_NAME:-$DEFAULT_IMAGE_NAME}"
@@ -951,19 +966,16 @@ main() {
951966
# Environment variable override
952967
image_tag="${IMAGE_TAG}"
953968
else
954-
# Default: branch_name with _release suffix
955-
image_tag="${branch_name}_release"
969+
# Default: branch_name with _release suffix, or 'latest' for main branch
970+
if [ "${branch_name}" = "main" ]; then
971+
image_tag="latest"
972+
else
973+
image_tag="${branch_name}_release"
974+
fi
956975
fi
957976

958977
export LINERA_IMAGE="${docker_registry}/${image_name}:${image_tag}"
959978
log INFO "Using remote Docker image: ${LINERA_IMAGE}"
960-
else
961-
# Local build
962-
export LINERA_IMAGE="${LINERA_IMAGE:-linera}"
963-
if ! build_local_image "${git_commit}" "${LINERA_IMAGE}"; then
964-
log ERROR "Failed to build local Docker image"
965-
exit 1
966-
fi
967979
fi
968980

969981
# Generate genesis URL if not provided

0 commit comments

Comments
 (0)