Skip to content

Commit

Permalink
feat: add Dockerfile (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaRedHand authored Apr 24, 2024
1 parent 41b67ed commit 5a53ee2
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
_build/
.elixir_ls/
.github/
.vscode/
bench/
deps/
docs/
level_db/
metrics/
priv/
test/
tmp/
.all-contributorsrc
.credo.exs
.formatter.exs
.spectest_version
flake.*
native/**/target/
Dockerfile
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# libp2p port
FROM golang:1.21.3 AS libp2p_builder
LABEL stage=builder

RUN mkdir /libp2p_port
WORKDIR /libp2p_port

COPY native/libp2p_port /libp2p_port

RUN go build -o libp2p_port


# Main image
FROM elixir:1.16.2-otp-26

RUN mkdir /consensus
WORKDIR /consensus

ENV MIX_ENV=prod

RUN mix local.hex --force

# Install dependencies
RUN apt-get update && apt-get install -y cmake

# Install rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="${PATH}:/root/.cargo/bin"

COPY . .
COPY --from=libp2p_builder /libp2p_port/libp2p_port /consensus/priv/native/libp2p_port

RUN mix deps.get
RUN mix compile

ENTRYPOINT [ "iex", "-S", "mix", "run", "--"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ make dialyzer # Runs type-checker
Source code can be formatted using `make fmt`.
This formats not only the Elixir code, but also the code under [`native/`](./native/).

### Docker

The repo includes a `Dockerfile` for the consensus client. It can be built with:

```bash
docker build -t consensus .
```

Then you run it with `docker run`, adding CLI flags as needed:

```bash
docker run consensus --checkpoint-sync <url> --network <network> ...
```

## Consensus spec tests

You can run all of them with:
Expand Down
2 changes: 1 addition & 1 deletion lib/libp2p_port.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do

require Logger

@port_name "priv/native/libp2p_port"
@port_name Application.app_dir(:lambda_ethereum_consensus, ["priv", "native", "libp2p_port"])

@default_args [
listen_addr: [],
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule LambdaEthereumConsensus.MixProject do
[
app: :lambda_ethereum_consensus,
version: "0.1.0",
elixir: "~> 1.15",
elixir: "~> 1.16",
start_permanent: Mix.env() == :prod,
deps: deps(),
dialyzer: dialyzer(),
Expand Down Expand Up @@ -39,7 +39,7 @@ defmodule LambdaEthereumConsensus.MixProject do
{:jason, "~> 1.4"},
{:scrypt_elixir, "~> 0.1.1", hex: :scrypt_elixir_copy},
{:joken, "~> 2.6"},
{:rustler, "~> 0.32"},
{:rustler, "~> 0.32", runtime: false},
{:broadway, "~> 1.0"},
{:snappyer, "~> 1.2"},
{:yaml_elixir, "~> 2.8"},
Expand Down

0 comments on commit 5a53ee2

Please sign in to comment.