Skip to content

Commit

Permalink
fix: docker (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbcaron authored Jul 8, 2024
1 parent 6d5f208 commit 1f7f87e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 34 deletions.
10 changes: 1 addition & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@
// As such, this path would have to change accordingly.
"program": "${workspaceFolder}/target/debug/deoxys",
// If you wish to supply arguments/parameters to the program, supply them below:
"args": [
"--deoxys",
"--network",
"main",
"--rpc-cors",
"all",
"--pruning",
"archive"
],
"args": ["--network=test"],
// Working folder for execution. Change as necessary if program requires a different value:
"cwd": "${workspaceFolder}",
"terminal": "integrated",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- fix: docker
- fix: pending storage & sequencer_provider
- refactor: support pending blocks & db crate
- refactor: new crate exec
Expand Down
26 changes: 14 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Stage 1: Build the application
FROM rust:bookworm AS builder
FROM rust:1.78 as builder

# Install build dependencies
RUN apt-get -y update && \
apt-get install -y --no-install-recommends \
clang \
protobuf-compiler \
build-essential
apt-get install -y clang && \
apt-get autoremove -y; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /usr/src/
WORKDIR /usr/src/deoxys/

# Copy the source code into the container
COPY . .
COPY Cargo.toml Cargo.lock ./
COPY crates crates

# Build the application in release mode
RUN cargo build --release
Expand All @@ -22,15 +23,16 @@ FROM debian:bookworm

# Install runtime dependencies
RUN apt-get -y update && \
apt-get install -y --no-install-recommends \
clang \
protobuf-compiler
apt-get install -y openssl ca-certificates tini &&\
apt-get autoremove -y; \
apt-get clean; \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /usr/local/bin

# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/target/release/deoxys .
COPY --from=builder /usr/src/deoxys/target/release/deoxys .

# Set the entrypoint
ENTRYPOINT ["./deoxys"]
CMD ["./deoxys"]
8 changes: 7 additions & 1 deletion crates/primitives/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ where
static CTRL_C: AtomicBool = AtomicBool::new(false);

pub async fn graceful_shutdown() {
tokio::signal::ctrl_c().await.unwrap();
let mut sigint =
tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("SIGINT not supported");

tokio::select! {
_ = tokio::signal::ctrl_c() => {},
_ = sigint.recv() => {},
};
CTRL_C.store(true, Ordering::SeqCst);
}

Expand Down
48 changes: 37 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,40 @@ services:
- "${RPC_PORT:-9944}:9944"
volumes:
- $HOME/deoxys:/var/lib/deoxys
environment:
- ETHEREUM_API_URL=${ETHEREUM_API_URL}
command: >
--name deoxys
--base-path /var/lib/deoxys
--l1-endpoint ${ETHEREUM_API_URL}
--network main
--chain starknet
--rpc-port 9944
--rpc-external
--rpc-cors "*"
entrypoint: ["tini", "--"]
command:
[
"/usr/local/bin/deoxys",
"--base-path",
"/var/lib/deoxys",
"--network",
"main",
"--l1-endpoint",
"${L1_ENDPOINT}",
]
profiles:
- mainnet

deoxys-testnet:
build:
context: ./
dockerfile: Dockerfile
container_name: deoxys-testnet
restart: unless-stopped
ports:
- "${RPC_PORT:-9944}:9944"
volumes:
- $HOME/deoxys-testnet:/var/lib/deoxys-testnet
entrypoint: ["tini", "--"]
command:
[
"/usr/local/bin/deoxys",
"--base-path",
"/var/lib/deoxys-testnet",
"--network",
"test",
"--l1-endpoint",
"${L1_ENDPOINT}",
]
profiles:
- testnet
1 change: 0 additions & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[toolchain]
channel = "1.78"
components = ["rustfmt", "clippy", "rust-analyzer"]
targets = ["wasm32-unknown-unknown"]
profile = "minimal"

0 comments on commit 1f7f87e

Please sign in to comment.