From 7a6e14111c18c66a1ebe20e1972193f9037eeff5 Mon Sep 17 00:00:00 2001 From: Idan Shamam Date: Wed, 13 Nov 2024 11:51:39 +0200 Subject: [PATCH] Added dockerfile for sequencer-node, added option to provide container args in cdk8s --- config/sequencer/config.json | 18 +++++++++++++ deployments/images/sequencer/Dockerfile | 31 +++++++++++++++++++++++ deployments/sequencer/main.py | 7 ++--- deployments/sequencer/services/service.py | 4 ++- 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 config/sequencer/config.json create mode 100644 deployments/images/sequencer/Dockerfile diff --git a/config/sequencer/config.json b/config/sequencer/config.json new file mode 100644 index 0000000000..5d3a456571 --- /dev/null +++ b/config/sequencer/config.json @@ -0,0 +1,18 @@ +{ + "chain_id": "0x5", + "eth_fee_token_address": "0x6", + "strk_fee_token_address": "0x7", + "components.batcher.execution_mode": "Disabled", + "components.batcher.local_server_config.#is_none": true, + "components.consensus_manager.execution_mode": "Disabled", + "components.gateway.execution_mode": "Disabled", + "components.http_server.execution_mode": "Disabled", + "components.mempool.execution_mode": "Disabled", + "components.mempool_p2p.execution_mode": "Disabled", + "components.consensus_manager.local_server_config.#is_none": true, + "components.gateway.local_server_config.#is_none": true, + "components.http_server.local_server_config.#is_none": true, + "components.mempool.local_server_config.#is_none": true, + "components.mempool_p2p.local_server_config.#is_none": true, + "components.http_server.remote_server_config.#is_none": true +} \ No newline at end of file diff --git a/deployments/images/sequencer/Dockerfile b/deployments/images/sequencer/Dockerfile new file mode 100644 index 0000000000..93f59a18db --- /dev/null +++ b/deployments/images/sequencer/Dockerfile @@ -0,0 +1,31 @@ +# syntax = devthefuture/dockerfile-x + +INCLUDE deployments/images/base/Dockerfile + + +# Compile the sequencer_node crate in release mode, ensuring dependencies are locked. +FROM base AS builder +COPY . . +RUN cargo build --release --package starknet_sequencer_node + +FROM base AS sequencer + +ENV ID=1000 +WORKDIR /app +COPY --from=builder /target/release/starknet_sequencer_node /app/target/release/starknet_sequencer_node +COPY config/ config/ + +# Create a new user "sequencer". +RUN set -ex; \ + addgroup --gid ${ID} sequencer; \ + adduser --ingroup $(getent group ${ID} | cut -d: -f1) --uid ${ID} --gecos "" --disabled-password --home /app sequencer; \ + chown -R sequencer:sequencer /app + +# Expose RPC and monitoring ports. +EXPOSE 8080 8081 8082 + +# Switch to the new user. +USER ${ID} + +# Set the entrypoint to use tini to manage the process. +ENTRYPOINT ["tini", "--", "/app/target/release/starknet_sequencer_node"] diff --git a/deployments/sequencer/main.py b/deployments/sequencer/main.py index 2bc32c8705..09b8f5c1df 100644 --- a/deployments/sequencer/main.py +++ b/deployments/sequencer/main.py @@ -39,7 +39,8 @@ def __init__( self.service = Service( self, "sequencer-node", - image="us.gcr.io/starkware-dev/sequencer-node:0.0.3", + image="us.gcr.io/starkware-dev/sequencer-node-test:0.0.1-dev.1", + args=["--config_file", "/app/config/sequencer/config.json"], port_mappings=[ PortMappings(name="http", port=80, container_port=8080), PortMappings(name="rpc", port=8081, container_port=8081), @@ -49,7 +50,7 @@ def __init__( replicas=1, config=config, health_check=HealthCheck( - startup_probe=Probe(port=8082, path="/monitoring/NodeVersion", period_seconds=10, failure_threshold=10, timeout_seconds=5), + startup_probe=Probe(port=8082, path="/monitoring/nodeVersion", period_seconds=10, failure_threshold=10, timeout_seconds=5), readiness_probe=Probe(port=8082, path="/monitoring/ready", period_seconds=10, failure_threshold=5, timeout_seconds=5), liveness_probe=Probe(port=8082, path="/monitoring/alive", period_seconds=10, failure_threshold=5, timeout_seconds=5) ), @@ -99,7 +100,7 @@ def __init__( scope=app, name="sequencer-node", namespace="sequencer", - config=SequencerDevConfig(mount_path="/app/config") + config=None ) a = SequencerSystem( scope=app, diff --git a/deployments/sequencer/services/service.py b/deployments/sequencer/services/service.py index 5e8e237498..c5f479c8e9 100644 --- a/deployments/sequencer/services/service.py +++ b/deployments/sequencer/services/service.py @@ -20,7 +20,8 @@ def __init__( port_mappings: Optional[List[PortMappings]] = None, config: Optional[Config] = None, health_check: Optional[HealthCheck] = None, - pvc: Optional[PersistentVolumeClaim] = None + pvc: Optional[PersistentVolumeClaim] = None, + args: Optional[List[str]] = None ): super().__init__(scope, id) @@ -63,6 +64,7 @@ def __init__( k8s.Container( name="sequencer", image=image, + args=args or [], ports=[k8s.ContainerPort(container_port=port_map.get("container_port")) for port_map in port_mappings or []], startup_probe=k8s.Probe( http_get=k8s.HttpGetAction(