Skip to content

Commit

Permalink
wip : compose for devnet
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs committed Jun 16, 2023
1 parent a7e996c commit 2701c9c
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
86 changes: 86 additions & 0 deletions scripts/devnet/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Docker compose file to run a local devnet.
# The devnet consists of a:
# - Lotus node (2k build),
# - Lotus miner (2k build),
# - Forest node.

version: "3.7"

services:
lotus_init:
build:
context: .
dockerfile: lotus.dockerfile
volumes:
- filecoin-proofs:/var/tmp/filecoin-proof-parameters
- lotus-data:/lotus_data
env_file:
- lotus.env
entrypoint: ["/bin/bash", "-c" ]
command:
- |
lotus fetch-params 2048
if [ ! -f /lotus_data/NODE_INITIALISED ]; then
lotus-seed --sector-dir /lotus_data/genesis-sectors pre-seal --sector-size 2KiB --num-sectors 2
lotus-seed --sector-dir /lotus_data/genesis-sectors genesis new /lotus_data/localnet.json
lotus-seed --sector-dir /lotus_data/genesis-sectors genesis add-miner /lotus_data/localnet.json /lotus_data/genesis-sectors/pre-seal-t01000.json
touch /lotus_data/NODE_INITIALISED
fi
lotus_node:
depends_on:
lotus_init:
condition: service_completed_successfully
build:
context: .
dockerfile: lotus.dockerfile
container_name: lotus
networks:
- devnet
volumes:
- filecoin-proofs:/var/tmp/filecoin-proof-parameters
- lotus-data:/lotus_data
entrypoint: ["/bin/bash", "-c" ]
ports:
- 1234:1234
- 9090:9090
env_file:
- lotus.env
command:
- |
lotus daemon --lotus-make-genesis=/lotus_data/devgen.car --genesis-template=/lotus_data/localnet.json --bootstrap=false
lotus_miner:
depends_on:
lotus_init:
condition: service_completed_successfully
build:
context: .
dockerfile: lotus.dockerfile
container_name: lotus-miner
networks:
- devnet
volumes:
- filecoin-proofs:/var/tmp/filecoin-proof-parameters
- lotus-data:/lotus_data
entrypoint: ["/bin/bash", "-c" ]
ports:
- 2345:2345
env_file:
- lotus-miner.env
restart: on-failure # lotus node might not be ready
command:
- |
if [ ! -f /lotus_data/MINER_INITIALISED ]; then
lotus wallet import --as-default /lotus_data/genesis-sectors/pre-seal-t01000.key
lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=/lotus_data/genesis-sectors --pre-sealed-metadata=/lotus_data/genesis-sectors/pre-seal-t01000.json --nosync
touch /lotus_data/MINER_INITIALISED
fi
lotus-miner run --nosync
volumes:
filecoin-proofs:
lotus-data:

networks:
devnet:
7 changes: 7 additions & 0 deletions scripts/devnet/lotus-miner.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LOTUS_PATH=/lotus_data/lotus-local-net
LOTUS_MINER_PATH=/lotus_data/lotus-miner-local-net
LOTUS_SKIP_GENESIS_CHECK=_yes_
CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
CGO_CFLAGS="-D__BLST_PORTABLE__"
LOTUS_API_LISTENADDRESS=/dns/lotus/tcp/2345/http
LOTUS_API_LISTENADDRESS=/dns/lotus-miner/tcp/2345/http
30 changes: 30 additions & 0 deletions scripts/devnet/lotus.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Lotus binaries image, to be used in the local devnet with Forest.
FROM golang:1.19.7-buster AS lotus-builder

ARG LOTUS_TAG=v1.23.0

RUN apt-get update && apt-get install -y ca-certificates build-essential clang ocl-icd-opencl-dev ocl-icd-libopencl1 jq libhwloc-dev

WORKDIR /lotus
RUN git clone --depth 1 --branch ${LOTUS_TAG} https://github.com/filecoin-project/lotus.git . && make 2k

FROM ubuntu:22.04

# Need to copy the relevant shared libraries from the builder image.
# See https://github.com/filecoin-project/lotus/blob/master/Dockerfile
COPY --from=lotus-builder /etc/ssl/certs /etc/ssl/certs
COPY --from=lotus-builder /lib/*/libdl.so.2 /lib/
COPY --from=lotus-builder /lib/*/librt.so.1 /lib/
COPY --from=lotus-builder /lib/*/libgcc_s.so.1 /lib/
COPY --from=lotus-builder /lib/*/libutil.so.1 /lib/
COPY --from=lotus-builder /usr/lib/*/libltdl.so.7 /lib/
COPY --from=lotus-builder /usr/lib/*/libnuma.so.1 /lib/
COPY --from=lotus-builder /usr/lib/*/libhwloc.so.5 /lib/
COPY --from=lotus-builder /usr/lib/*/libOpenCL.so.1 /lib/

# Copy only the binaries relevant for the devnet
COPY --from=lotus-builder /lotus/lotus /lotus/lotus-miner /lotus/lotus-seed /usr/local/bin/

WORKDIR /lotus

CMD ["/bin/bash"]
6 changes: 6 additions & 0 deletions scripts/devnet/lotus.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LOTUS_PATH=/lotus_data/lotus-local-net
LOTUS_MINER_PATH=/lotus_data/lotus-miner-local-net
LOTUS_SKIP_GENESIS_CHECK=_yes_
CGO_CFLAGS_ALLOW="-D__BLST_PORTABLE__"
CGO_CFLAGS="-D__BLST_PORTABLE__"
LOTUS_API_LISTENADDRESS=/dns/lotus/tcp/1234/http

0 comments on commit 2701c9c

Please sign in to comment.