Skip to content

Commit

Permalink
Basic bin
Browse files Browse the repository at this point in the history
  • Loading branch information
Dzejkop committed Jan 26, 2024
1 parent 2d95054 commit c6a15c4
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
target/
.git
README.md
README.md
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
clap = { verison = "4.4.18", features = ["derive"] }
clap = { version = "4.4.18", features = ["derive"] }
config = "0.13.4"
criterion = "0.5.1"
eyre = "0.6.11"
Expand All @@ -14,13 +14,13 @@ sqlx = { version = "0.7.3", features = [
"postgres",
"chrono",
] }
telemetry-batteries = { git = "https://github.com/worldcoin/telemetry-batteries.git", commit = "c6816624415ae194da5203a5161621a9e10ad3b0" }
telemetry-batteries = { git = "https://github.com/worldcoin/telemetry-batteries.git", rev = "c6816624415ae194da5203a5161621a9e10ad3b0" }
tokio = { version = "1.35.1", features = ["macros"] }
tracing = "0.1.40"

[[bin]]
name = "service"
path = "bin/service.rs"
name = "mpc-node"
path = "bin/mpc_node.rs"

[[bench]]
name = "example"
Expand Down
40 changes: 39 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
FROM rust:1.75.0 AS chef-builder
FROM debian:12 as build-env

WORKDIR /src

# Install dependencies
RUN apt-get update && \
apt-get install -y \
curl build-essential \
libssl-dev texinfo \
libcap2-bin pkg-config

# TODO: Use a specific version of rustup
# Install rustup
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y

COPY . .

# Set environment variables
ENV PATH="/root/.cargo/bin:${PATH}"
ENV RUSTUP_HOME="/root/.rustup"
ENV CARGO_HOME="/root/.cargo"

# Install the toolchain
RUN rustup component add cargo

# Build the binary
RUN cargo fetch
RUN cargo build --release --no-default-features

# Make sure it runs
RUN /src/target/release/mpc-node --version

# cc variant because we need libgcc and others
FROM gcr.io/distroless/cc-debian12:nonroot

# Copy the mpc-node binary
COPY --from=build-env --chown=0:10001 --chmod=010 /src/target/release/mpc-node /bin/mpc-node

ENTRYPOINT [ "/bin/mpc-node" ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# service-template-rs
# MPC Service
4 changes: 3 additions & 1 deletion bin/service.rs → bin/mpc_node.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use clap::Parser;
use telemetry_batteries::{metrics::batteries::StatsdBattery, tracing::batteries::DatadogBattery};
use telemetry_batteries::metrics::batteries::StatsdBattery;
use telemetry_batteries::tracing::batteries::DatadogBattery;

pub const SERVICE_NAME: &str = "service";

Expand All @@ -10,6 +11,7 @@ pub const METRICS_BUFFER_SIZE: usize = 1024;
pub const METRICS_PREFIX: &str = "service";

#[derive(Parser)]
#[clap(version)]
pub struct Args {}

#[tokio::main]
Expand Down
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly-2024-01-26"
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
group_imports = "StdExternalCrate"
imports_granularity = "Module"
max_width = 80

0 comments on commit c6a15c4

Please sign in to comment.