Skip to content

Instantly share code, notes, and snippets.

@glihm
Last active April 23, 2023 05:18
Show Gist options
  • Save glihm/994efc48b2030c361cf422fe1c37dd63 to your computer and use it in GitHub Desktop.
Save glihm/994efc48b2030c361cf422fe1c37dd63 to your computer and use it in GitHub Desktop.
Beerus dockerize

Beerus dockerize

Dockerfile

Dockerfile must be placed at the root of beerus project.

FROM rust:1.69 as builder

WORKDIR /beerus
COPY . .
RUN cargo build --all --locked --release

FROM ubuntu:22.04
RUN apt-get update && apt-get install -y ca-certificates
COPY --from=builder /beerus/target/release/beerus /usr/local/bin/
COPY --from=builder /beerus/target/release/beerus-rpc /usr/local/bin/

LABEL description="Docker image for Beerus, light client for Starknet." \
      image.authors="Keep Starknet Strange team." \
      image.description="Docker image for Beerus, light client for Starknet." \
      image.source="https://github.com/keep-starknet-strange/beerus" \
      image.documentation="https://github.com/keep-starknet-strange/beerus"

EXPOSE 3030

# Uncomment the line below for helios RPC if we still have 2 endpoints.
#EXPOSE 3031

# Can be changed to beerus if needed. But RPC has more usages.
ENTRYPOINT ["/usr/local/bin/beerus-rpc"]

Do not forget to add the following .dockerignore file at the same level of the Dockerfile. This avoid copying all build artifacts and git stuff.

**/target/
.git
.github

To build, go into the beerus root directory and run: docker build -t beerus-rpc .

Environment file

To run the container correctly, an environment file is expected to set the variables used by beerus. The following file is an example:

ETHEREUM_NETWORK=mainnet
ETHEREUM_CONSENSUS_RPC_URL=https://www.lightclientdata.org
ETHEREUM_EXECUTION_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/XXXX
STARKNET_RPC_URL=https://starknet-mainnet.infura.io/v3/XXXX
DATA_DIR=/tmp/

Run the container

docker run --rm --init --env-file ../beerus_docker.env beerus-rpc

Some details here:

  1. --init option is used to ensure a PID 1 process is started before our. Usefull to keep the possibility to kill the container with signals.
  2. --rm to auto remove the container when killed / stopped.
  3. --env-file the path to the file of the previous step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment