Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
fix data persistence option in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyke-bot committed Oct 26, 2023
1 parent 85bc805 commit 2c198e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
FROM lukemathwalker/cargo-chef:latest-rust-1-slim-buster AS chef
WORKDIR /app/
RUN apt update && apt install -y libssl-dev
RUN apt update && apt install -y libssl-dev pkg-config

FROM chef AS planner

COPY src ./src
COPY Cargo.toml .
COPY Cargo.lock .

RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

COPY src ./src
COPY Cargo.toml .
COPY Cargo.lock .

RUN cargo build --release

FROM debian:buster-slim
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Multiple endpoints/chains can be configured to be cached.
docker run \
-d \
-p 8124:8124 \
-v ./data/:/data/ \
-e DATA_PERSISTENCE=1 \
-e ENDPOINTS="eth-chain=https://rpc.ankr.com/eth,bsc-chain=https://rpc.ankr.com/bsc" \
--name cached-eth-rpc \
ghcr.io/tonyke-bot/cached-eth-rpc
Expand Down
9 changes: 7 additions & 2 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

IFS=',' read -ra PARTS <<< "$ENDPOINTS"
ARGUMENTS=""
Expand All @@ -7,4 +7,9 @@ for part in "${PARTS[@]}"; do
ARGUMENTS+="--endpoint $part "
done

$1 --port 8124 --bind 0.0.0.0 $ARGUMENTS
# if DATA_PERSISTENCE = 1 is set, then use it
if [ "$DATA_PERSISTENCE" = "1" ]; then
ARGUMENTS+="--datadir /data"
fi

exec $1 --port 8124 --bind 0.0.0.0 $ARGUMENTS
2 changes: 0 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ pub struct Cli {
#[arg(short, long, default_value = "127.0.0.1")]
pub bind: String,

/// Name of the person to greet
#[arg(short, long, default_value = "8124")]
pub port: u16,

/// Number of times to greet
#[arg(short, long = "endpoint", value_parser = endpoint_parser)]
pub endpoints: Vec<(String, Url)>,

Expand Down

0 comments on commit 2c198e4

Please sign in to comment.