Skip to content

Commit 30d2ee3

Browse files
authored
feat: add docker image (#35)
1 parent d0ea86c commit 30d2ee3

8 files changed

Lines changed: 116 additions & 23 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy on DockerHub
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
name: Push
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Login to DockerHub
21+
uses: docker/login-action@v3
22+
with:
23+
username: ${{ secrets.USERNAME }}
24+
password: ${{ secrets.TOKEN }}
25+
26+
- name: Build and push
27+
uses: docker/build-push-action@v6
28+
with:
29+
context: .
30+
platforms: linux/amd64, linux/arm64/v8
31+
push: true
32+
tags: yoeight/gethdb:latest

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM rust:slim-bookworm AS build
2+
3+
WORKDIR /build
4+
COPY ./geth-common/ ./geth-common
5+
COPY ./geth-domain/ ./geth-domain
6+
COPY ./geth-engine/ ./geth-engine
7+
COPY ./geth-grpc/ ./geth-grpc
8+
COPY ./geth-mikoshi/ ./geth-mikoshi
9+
COPY ./geth-node/ ./geth-node
10+
11+
WORKDIR /build/.git
12+
COPY ./.git/ .
13+
14+
RUN apt update && apt install -y protobuf-compiler
15+
16+
WORKDIR /build
17+
RUN cargo install --path geth-node --root /geth
18+
19+
FROM build AS binaries
20+
21+
ARG UID=1000
22+
ARG GID=1000
23+
24+
WORKDIR /opt/gethdb
25+
26+
RUN addgroup --gid ${GID} "geth" && \
27+
adduser \
28+
--disabled-password \
29+
--gecos "" \
30+
--ingroup "geth" \
31+
--no-create-home \
32+
--uid ${UID} \
33+
"geth"
34+
35+
COPY --chown=geth:geth --from=build ./geth/bin/geth-node ./geth-node
36+
37+
RUN mkdir -p /var/lib/gethdb && \
38+
mkdir -p /var/log/gethdb && \
39+
mkdir -p /etc/gethdb && \
40+
chown -R geth:geth /var/lib/gethdb /var/log/gethdb /etc/gethdb
41+
42+
USER geth
43+
44+
VOLUME /var/lib/gethdb /var/log/gethdb
45+
46+
EXPOSE 2113/tcp
47+
48+
ENTRYPOINT [ "/opt/gethdb/geth-node" ]
49+
CMD [ "--host", "0.0.0.0", "--db", "/var/lib/gethdb" ]

README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ data structures and observe their behavior in real-life scenarios.
1313
This is a side project that I work on during my spare time. It is not production-ready, and most of the code is
1414
undocumented. Although the code is written entirely in Rust, performance is not a primary focus.
1515

16-
## Supported platforms
17-
18-
The codebase should compile on any 64-bit platform supported by the Rust compiler. So far, it has been tested on Linux,
19-
macOS, and Windows. Please note that Linux will remain the primary target
20-
2116
## Features
2217

2318
The core engine is a NoSQL, append-only, and immutable database with the following key features:
@@ -30,6 +25,31 @@ The core engine is a NoSQL, append-only, and immutable database with the followi
3025
* Supports OpenTelemetry logs and traces, which can be sent to any OpenTelemetry-compatible server when configured, or disabled entirely if preferred.
3126
* Cluster functionality using a homemade Raft implementation (though it is not fully integrated yet).
3227

28+
## Supported platforms
29+
30+
The codebase should compile on any 64-bit platform supported by the Rust compiler. So far, it has been tested on Linux,
31+
macOS, and Windows. Please note that Linux will remain the primary target
32+
33+
## Build from source
34+
35+
You need to have the latest Rust toolchain installed and also `protoc` in your $PATH. Then run this command:
36+
37+
```
38+
cargo build
39+
```
40+
41+
## Docker
42+
43+
```
44+
docker pull yoeight/gethdb:latest
45+
```
46+
47+
At that stage, there is no other version besides `latest`. A new image is pushed every time a commit is pushed to the `master` branch.
48+
49+
The image supports:
50+
- linux/amd64
51+
- linux/arm64/v8
52+
3353
## What's next?
3454

3555
This is the features I want to work on

geth-engine/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ git = "https://github.com/YoEight/pyro.git"
3333

3434
[dependencies.clap]
3535
version = "4.5"
36-
features = ["derive"]
36+
features = ["derive", "env"]
3737

3838
[dependencies.tracing-subscriber]
3939
version = "0.3"

geth-engine/src/options.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ use clap::{Args, Parser};
22

33
#[derive(Args, Debug, Clone, Default)]
44
pub struct Telemetry {
5-
#[arg(long = "telemetry-disabled", default_value = "false")]
5+
#[arg(
6+
long = "telemetry-disabled",
7+
default_value = "false",
8+
env = "GETH_TELEMETRY_DISABLED"
9+
)]
610
pub disabled: bool,
711

812
/// OpenTelemetry compatible endpoint where telemetry data is sent
9-
#[arg(long = "telemetry-endpoint")]
13+
#[arg(long = "telemetry-endpoint", env = "GETH_TELEMETRY_ENDPOINT")]
1014
pub endpoint: Option<String>,
1115

1216
#[arg(long = "telemetry-event-filters")]
@@ -19,15 +23,15 @@ pub struct Telemetry {
1923
#[command(propagate_version = true)]
2024
pub struct Options {
2125
/// Host IP address.
22-
#[arg(long, default_value = "127.0.0.1")]
26+
#[arg(long, default_value = "127.0.0.1", env = "GETH_HOST")]
2327
pub host: String,
2428

2529
/// Host Port.
26-
#[arg(long, default_value = "2113")]
30+
#[arg(long, default_value = "2113", env = "GETH_PORT")]
2731
pub port: u16,
2832

2933
/// Data directory. If you want to use the in-memory storage, set this to `in_mem`
30-
#[arg(long, default_value = "./geth")]
34+
#[arg(long, default_value = "./geth", env = "GETH_DB")]
3135
pub db: String,
3236

3337
#[command(flatten)]

geth-node/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ features = ["full"]
1313
[dependencies]
1414
clap = "*"
1515
eyre = "0.6"
16-
tracing = "0.1"
17-
tracing-subscriber = "0.3"

geth-node/src/main.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
use clap::Parser;
2-
use tracing::Level;
3-
use tracing_subscriber::FmtSubscriber;
42

53
#[tokio::main]
64
async fn main() -> eyre::Result<()> {
7-
let subscriber = FmtSubscriber::builder()
8-
.with_max_level(Level::DEBUG)
9-
.finish();
10-
11-
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
12-
135
let options = geth_engine::Options::parse();
146

157
geth_engine::run(options).await

0 commit comments

Comments
 (0)