Skip to content

Commit dad3854

Browse files
committed
Stop using init and entrypoint scripts (#4830)
## Motivation The init and entrypoint shell scripts (server-entrypoint.sh, proxy-entrypoint.sh, etc.) were thin wrappers around binary calls that passed arguments to the Linera binaries. This meant that any time we needed to change initialization or entrypoint arguments (e.g., adding new flags, changing default values), we had to rebuild the Docker images, which is inefficient and couples configuration to the image build process. ## Proposal This PR removes all init and entrypoint shell scripts and embeds their logic directly into the configuration files: - **Deleted 7 shell scripts** from the codebase: - `docker/server-entrypoint.sh`, `docker/server-init.sh` - `docker/proxy-entrypoint.sh`, `docker/proxy-init.sh` - `docker/compose-server-entrypoint.sh`, `docker/compose-proxy-entrypoint.sh`, `docker/compose-server-init.sh` - **Updated Kubernetes templates** (shards.yaml and proxy.yaml): - Replaced script calls with inline shell commands in both initContainers and main containers - All binary arguments are now specified directly in the YAML - **Updated Docker Compose** (docker-compose.yml): - Replaced script calls with direct binary invocations using command arrays - Init logic is now inline shell script in the shard-init service - **Updated Dockerfile**: - Removed COPY commands for all deleted scripts **Benefits:** - Binary configuration changes (flags, environment variables) no longer require Docker image rebuilds - Arguments are visible directly in the deployment configs - Simpler deployment pipeline - fewer moving parts - Easier to understand what arguments are being passed to binaries ## Test Plan - Verified all shell scripts are deleted from the repository - Verified Dockerfile no longer references the deleted scripts - Checked that Kubernetes YAML templates have valid syntax - Checked that Docker Compose YAML has valid syntax - All binary arguments are correctly passed via command-line flags in the configs ## Release Plan - These changes should be backported to the latest `testnet` branch, then be released in a validator hotfix.
1 parent 0ecb7b0 commit dad3854

File tree

11 files changed

+108
-132
lines changed

11 files changed

+108
-132
lines changed

docker/Dockerfile

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,3 @@ COPY --from=binaries \
119119
linera-server \
120120
linera-proxy \
121121
./
122-
123-
COPY --chmod=755 \
124-
docker/server-entrypoint.sh \
125-
docker/server-init.sh \
126-
docker/proxy-entrypoint.sh \
127-
docker/proxy-init.sh \
128-
docker/compose-server-entrypoint.sh \
129-
docker/compose-proxy-entrypoint.sh \
130-
docker/compose-server-init.sh \
131-
./

docker/compose-proxy-entrypoint.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

docker/compose-server-entrypoint.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

docker/compose-server-init.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

docker/docker-compose.yml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ services:
4747
container_name: proxy
4848
ports:
4949
- "19100:19100"
50-
command: ["./compose-proxy-entrypoint.sh", "1"]
50+
command:
51+
- ./linera-proxy
52+
- --storage
53+
- scylladb:tcp:scylla:9042
54+
- --storage-replication-factor
55+
- "1"
56+
- /config/server.json
5157
volumes:
5258
- .:/config
5359
labels:
@@ -60,7 +66,17 @@ services:
6066
image: "${LINERA_IMAGE:-us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera:testnet_conway_release}"
6167
deploy:
6268
replicas: 4
63-
command: ["./compose-server-entrypoint.sh", "scylladb:tcp:scylla:9042", "1"]
69+
command:
70+
- ./linera-server
71+
- run
72+
- --storage
73+
- scylladb:tcp:scylla:9042
74+
- --server
75+
- /config/server.json
76+
- --shard
77+
- "0"
78+
- --storage-replication-factor
79+
- "1"
6480
volumes:
6581
- .:/config
6682
labels:
@@ -72,7 +88,30 @@ services:
7288
shard-init:
7389
image: "${LINERA_IMAGE:-us-docker.pkg.dev/linera-io-dev/linera-public-registry/linera:testnet_conway_release}"
7490
container_name: shard-init
75-
command: ["./compose-server-init.sh", "scylladb:tcp:scylla:9042", "1"]
91+
command:
92+
- sh
93+
- -c
94+
- |
95+
while true; do
96+
./linera storage check-existence --storage scylladb:tcp:scylla:9042
97+
status=$$?
98+
if [ $$status -eq 0 ]; then
99+
echo "Database already exists, no need to initialize."
100+
exit 0
101+
elif [ $$status -eq 1 ]; then
102+
echo "Database does not exist, attempting to initialize..."
103+
if ./linera storage initialize --storage scylladb:tcp:scylla:9042 --genesis /config/genesis.json; then
104+
echo "Initialization successful."
105+
exit 0
106+
else
107+
echo "Initialization failed, retrying in 5 seconds..."
108+
sleep 5
109+
fi
110+
else
111+
echo "An unexpected error occurred (status: $$status), retrying in 5 seconds..."
112+
sleep 5
113+
fi
114+
done
76115
volumes:
77116
- .:/config
78117
depends_on:

docker/proxy-entrypoint.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

docker/proxy-init.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

docker/server-entrypoint.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

docker/server-init.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

kubernetes/linera-validator/templates/proxy.yaml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,25 @@ spec:
5555
- name: linera-proxy-initializer
5656
image: {{ .Values.lineraImage }}
5757
imagePullPolicy: {{ .Values.lineraImagePullPolicy }}
58-
command: ["./proxy-init.sh"]
58+
command:
59+
- sh
60+
- -c
61+
- |
62+
while true; do
63+
./linera storage check-existence --storage "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042"
64+
status=$?
65+
if [ "$status" -eq 0 ]; then
66+
echo "Database already exists, no need to initialize."
67+
exit 0
68+
else
69+
if [ "$status" -eq 1 ]; then
70+
echo "Database does not exist, retrying in 5 seconds..."
71+
else
72+
echo "An unexpected error occurred (status: $status), retrying in 5 seconds..."
73+
fi
74+
sleep 5
75+
fi
76+
done
5977
env:
6078
- name: RUST_LOG
6179
value: {{ .Values.logLevel }}
@@ -72,7 +90,16 @@ spec:
7290
name: linera-port
7391
- containerPort: 20100
7492
name: private-port
75-
command: ["./proxy-entrypoint.sh", {{ .Values.storageReplicationFactor | quote }}]
93+
command:
94+
- sh
95+
- -c
96+
- |
97+
ORDINAL="${HOSTNAME##*-}"
98+
exec ./linera-proxy \
99+
--storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \
100+
--storage-replication-factor {{ .Values.storageReplicationFactor | quote }} \
101+
--id "$ORDINAL" \
102+
/config/server.json
76103
env:
77104
- name: RUST_LOG
78105
value: {{ .Values.logLevel }}

0 commit comments

Comments
 (0)