Skip to content

Commit 5a53ee2

Browse files
authored
feat: add Dockerfile (#1009)
1 parent 41b67ed commit 5a53ee2

File tree

5 files changed

+72
-3
lines changed

5 files changed

+72
-3
lines changed

.dockerignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
_build/
2+
.elixir_ls/
3+
.github/
4+
.vscode/
5+
bench/
6+
deps/
7+
docs/
8+
level_db/
9+
metrics/
10+
priv/
11+
test/
12+
tmp/
13+
.all-contributorsrc
14+
.credo.exs
15+
.formatter.exs
16+
.spectest_version
17+
flake.*
18+
native/**/target/
19+
Dockerfile

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# libp2p port
2+
FROM golang:1.21.3 AS libp2p_builder
3+
LABEL stage=builder
4+
5+
RUN mkdir /libp2p_port
6+
WORKDIR /libp2p_port
7+
8+
COPY native/libp2p_port /libp2p_port
9+
10+
RUN go build -o libp2p_port
11+
12+
13+
# Main image
14+
FROM elixir:1.16.2-otp-26
15+
16+
RUN mkdir /consensus
17+
WORKDIR /consensus
18+
19+
ENV MIX_ENV=prod
20+
21+
RUN mix local.hex --force
22+
23+
# Install dependencies
24+
RUN apt-get update && apt-get install -y cmake
25+
26+
# Install rust
27+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
28+
ENV PATH="${PATH}:/root/.cargo/bin"
29+
30+
COPY . .
31+
COPY --from=libp2p_builder /libp2p_port/libp2p_port /consensus/priv/native/libp2p_port
32+
33+
RUN mix deps.get
34+
RUN mix compile
35+
36+
ENTRYPOINT [ "iex", "-S", "mix", "run", "--"]

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@ make dialyzer # Runs type-checker
121121
Source code can be formatted using `make fmt`.
122122
This formats not only the Elixir code, but also the code under [`native/`](./native/).
123123

124+
### Docker
125+
126+
The repo includes a `Dockerfile` for the consensus client. It can be built with:
127+
128+
```bash
129+
docker build -t consensus .
130+
```
131+
132+
Then you run it with `docker run`, adding CLI flags as needed:
133+
134+
```bash
135+
docker run consensus --checkpoint-sync <url> --network <network> ...
136+
```
137+
124138
## Consensus spec tests
125139

126140
You can run all of them with:

lib/libp2p_port.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defmodule LambdaEthereumConsensus.Libp2pPort do
3737

3838
require Logger
3939

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

4242
@default_args [
4343
listen_addr: [],

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule LambdaEthereumConsensus.MixProject do
55
[
66
app: :lambda_ethereum_consensus,
77
version: "0.1.0",
8-
elixir: "~> 1.15",
8+
elixir: "~> 1.16",
99
start_permanent: Mix.env() == :prod,
1010
deps: deps(),
1111
dialyzer: dialyzer(),
@@ -39,7 +39,7 @@ defmodule LambdaEthereumConsensus.MixProject do
3939
{:jason, "~> 1.4"},
4040
{:scrypt_elixir, "~> 0.1.1", hex: :scrypt_elixir_copy},
4141
{:joken, "~> 2.6"},
42-
{:rustler, "~> 0.32"},
42+
{:rustler, "~> 0.32", runtime: false},
4343
{:broadway, "~> 1.0"},
4444
{:snappyer, "~> 1.2"},
4545
{:yaml_elixir, "~> 2.8"},

0 commit comments

Comments
 (0)