Skip to content

Commit 664e464

Browse files
authored
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 a86fea6 commit 664e464

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:latest}"
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:latest}"
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
@@ -63,7 +63,25 @@ spec:
6363
- name: linera-proxy-initializer
6464
image: {{ .Values.lineraImage }}
6565
imagePullPolicy: {{ .Values.lineraImagePullPolicy }}
66-
command: ["./proxy-init.sh"]
66+
command:
67+
- sh
68+
- -c
69+
- |
70+
while true; do
71+
./linera storage check-existence --storage "scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042"
72+
status=$?
73+
if [ "$status" -eq 0 ]; then
74+
echo "Database already exists, no need to initialize."
75+
exit 0
76+
else
77+
if [ "$status" -eq 1 ]; then
78+
echo "Database does not exist, retrying in 5 seconds..."
79+
else
80+
echo "An unexpected error occurred (status: $status), retrying in 5 seconds..."
81+
fi
82+
sleep 5
83+
fi
84+
done
6785
env:
6886
- name: RUST_LOG
6987
value: {{ .Values.logLevel }}
@@ -80,7 +98,16 @@ spec:
8098
name: linera-port
8199
- containerPort: 20100
82100
name: private-port
83-
command: ["./proxy-entrypoint.sh", {{ .Values.storageReplicationFactor | quote }}]
101+
command:
102+
- sh
103+
- -c
104+
- |
105+
ORDINAL="${HOSTNAME##*-}"
106+
exec ./linera-proxy \
107+
--storage scylladb:tcp:scylla-client.scylla.svc.cluster.local:9042 \
108+
--storage-replication-factor {{ .Values.storageReplicationFactor | quote }} \
109+
--id "$ORDINAL" \
110+
/config/server.json
84111
env:
85112
- name: RUST_LOG
86113
value: {{ .Values.logLevel }}

0 commit comments

Comments
 (0)