From beb957babf1a142076cb41c417d8a1211d0bff6b Mon Sep 17 00:00:00 2001 From: Daniyar Itegulov Date: Thu, 16 Nov 2023 08:24:41 +1100 Subject: [PATCH] feat: add localnet Dockerfile (#82) --- .dockerignore | 4 ++++ Dockerfile | 29 +++++++++++++++++++++++++++++ entrypoint.sh | 10 ++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..aabacb3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.github +scripts +target +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c9dba02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM rust:1.71 AS builder +WORKDIR /tmp/ + +# Copy from nearcore: +# https://github.com/near/nearcore/blob/master/Dockerfile +RUN apt-get update -qq && \ + apt-get install -y \ + git \ + cmake \ + g++ \ + pkg-config \ + libssl-dev \ + curl \ + llvm \ + clang + +COPY . . + +# build for release +RUN cargo build --release + +FROM debian:bookworm-slim as runtime +WORKDIR /near-lake-app + +RUN apt update && apt install -yy openssl ca-certificates jq + +COPY --from=builder /tmp/target/release/near-lake . +COPY ./entrypoint.sh entrypoint.sh +ENTRYPOINT [ "./entrypoint.sh" ] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a74ccc9 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Initialize NEAR Lake to generate config and genesis +/near-lake-app/near-lake init --chain-id localnet + +# Tweak nearcore config to track all shards +tmp=$(mktemp) +jq '.tracked_shards = [0]' /root/.near/config.json >"$tmp" && mv "$tmp" /root/.near/config.json + +/near-lake-app/near-lake run "$@"