Skip to content

Commit fb80af1

Browse files
authoredJan 18, 2022
Feature/docker compose (#566)
* docker-compose for interopnet Signed-off-by: Alexey Chernyshov <alexey.n.chernyshov@gmail.com>
1 parent 85cd7ad commit fb80af1

16 files changed

+151
-27
lines changed
 

‎.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake-build-debug
2+
cmake-build
3+
docker/interopnet
4+
docker/mainnet

‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bootstrap=/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWFYS1f31z
6868

6969
Start node
7070
```sh
71-
fuhon-node --repo fuhon-interopnet --genesis cpp-filecoin/core/node/main/interopnet.car
71+
fuhon-node --repo fuhon-interopnet --genesis docker/interopnet/genesis.car
7272
# you can omit --genesis flag after first run
7373
fuhon-node --repo fuhon-interopnet
7474
```
@@ -97,7 +97,7 @@ bootstrap=/dns4/node.glif.io/tcp/1235/p2p/12D3KooWBF8cpp65hp2u9LK5mh19x67ftAam84
9797

9898
Start node (first run may take some time)
9999
```sh
100-
fuhon-node --repo fuhon-mainnet --genesis cpp-filecoin/core/node/main/mainnet.car
100+
fuhon-node --repo fuhon-mainnet --genesis cpp-filecoin/core/docker/mainnet/genesis.car
101101
```
102102

103103
### Docker-compose example

‎core/miner/main/main.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,11 @@ namespace fc {
532532
api::makeRpc(*mapi,
533533
std::bind(mapi->AuthVerify, std::placeholders::_1)));
534534
auto mroutes{std::make_shared<api::Routes>()};
535+
mroutes->emplace("/health", [](auto &) {
536+
api::http::response<api::http::string_body> res;
537+
res.body() = "{\"status\":\"UP\"}";
538+
return api::WrapperResponse{std::move(res)};
539+
});
535540

536541
mroutes->insert({"/remote",
537542
api::makeAuthRoute(

‎docker-compose.yml

-16
This file was deleted.

‎docker/Dockerfile

+34-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
FROM ubuntu:20.04 AS base
22
RUN rm -f /etc/apt/apt.conf.d/docker-clean
3-
RUN --mount=type=cache,target=/var/cache/apt apt-get update
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
RUN --mount=type=cache,target=/var/cache/apt,sharing=shared apt-get update && apt-get install -y --no-install-recommends hwloc ocl-icd-* curl \
5+
&& rm -rf /var/lib/apt/lists/*
6+
RUN groupadd --gid 1000 fuhon && useradd --uid 1000 --gid fuhon fuhon
47

58
FROM base AS build
6-
RUN --mount=type=cache,target=/var/cache/apt DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends git curl rsync make ninja-build clang-9 jq python3-pip python-setuptools pkg-config ocl-icd-* opencl-headers libhwloc-dev
9+
RUN --mount=type=cache,target=/var/cache/apt,sharing=shared apt-get update && apt-get install -y --no-install-recommends git curl rsync make ninja-build clang-9 jq python3-pip python-setuptools pkg-config opencl-headers libhwloc-dev zlib1g-dev libbz2-dev liblzma-dev libssl-dev libxml2-dev \
10+
&& rm -rf /var/lib/apt/lists/*
711
RUN pip3 install scikit-build cmake requests gitpython pyyaml
812
RUN curl -sL https://golang.org/dl/go1.17.3.linux-amd64.tar.gz | tar -xz -C /usr/local
913
ENV PATH="$PATH:/usr/local/go/bin"
10-
COPY . /root/cpp-filecoin
11-
RUN --mount=type=cache,target=/root/.hunter/_Base/Cache CC=clang-9 CXX=clang++-9 cmake /root/cpp-filecoin -B /root/build -G Ninja -D CMAKE_BUILD_TYPE=Release -D TESTING=OFF
12-
RUN --mount=type=cache,target=/root/.hunter/_Base/Cache CC=clang-9 cmake --build /root/build --target fuhon-node
14+
COPY . /tmp/cpp-filecoin
15+
RUN --mount=type=cache,target=/tmp/.hunter/_Base/Cache CC=clang-9 CXX=clang++-9 cmake /tmp/cpp-filecoin -B /tmp/build -G Ninja -D CMAKE_BUILD_TYPE=Release -D TESTING=OFF
16+
RUN --mount=type=cache,target=/tmp/.hunter/_Base/Cache CC=clang-9 cmake --build /tmp/build --target fuhon-node fuhon-miner
1317

14-
FROM base
15-
RUN --mount=type=cache,target=/var/cache/apt apt-get install -y --no-install-recommends hwloc ocl-icd-*
16-
COPY core/node/main/mainnet.car /root/.
17-
COPY --from=build /root/build/bin/fuhon-node /root/.
18+
FROM base AS fuhon-miner
19+
RUN --mount=type=cache,target=/var/cache/apt,sharing=shared apt-get update && apt-get install -y --no-install-recommends libarchive13 libssl1.1 \
20+
&& rm -rf /var/lib/apt/lists/*
21+
# cmake built libarchive has API v17, but provided version is v13 (https://github.com/libarchive/libarchive/issues/1236)
22+
RUN ln -s /lib/x86_64-linux-gnu/libarchive.so.13 /lib/x86_64-linux-gnu/libarchive.so.17
23+
COPY --from=build /tmp/build/bin/fuhon-miner /usr/local/bin
24+
COPY docker/miner_entrypoint.sh /
25+
RUN chmod +x /miner_entrypoint.sh
26+
USER fuhon
27+
RUN mkdir /tmp/fuhon
28+
WORKDIR /tmp/fuhon
29+
ENTRYPOINT ["/miner_entrypoint.sh"]
30+
CMD ["fuhon-miner", "--repo", "fuhon-node-repo", "--miner-repo", "fuhon-miner-repo"]
31+
HEALTHCHECK --interval=5s --timeout=10s CMD curl http://127.0.0.1:1234/health || exit 1
32+
33+
FROM base AS fuhon-node
34+
COPY --from=build /tmp/build/bin/fuhon-node /usr/local/bin
35+
COPY docker/node_entrypoint.sh /
36+
RUN chmod +x /node_entrypoint.sh
1837
EXPOSE 1234 2000
38+
USER fuhon
39+
RUN mkdir /tmp/fuhon
40+
WORKDIR /tmp/fuhon
41+
ENTRYPOINT ["/node_entrypoint.sh"]
42+
CMD ["fuhon-node", "--config", "fuhon-node.cfg", "--genesis" ,"genesis.car", "--repo", "fuhon-node-repo"]
43+
HEALTHCHECK --interval=5s --timeout=10s CMD curl http://127.0.0.1:1234/health || exit 1

‎docker/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Prerequisites
2+
3+
[Docker BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/#to-enable-buildkit-builds)
4+
5+
`DOCKER_BUILDKIT=1` environment variable must be set to enable BuildKit.
6+
7+
## Build
8+
9+
To build docker image from the current context. It is advised to ignore binaries and large files from docker build context.
10+
11+
docker build .. -f Dockerfile
12+
13+
There are 2 targets `fuhon-node` and `fuhon-miner` declared in Dockerfile. To build a specific target use `-t` option.

‎docker/docker-compose-interopnet.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "3.0"
2+
3+
services:
4+
fuhon-node:
5+
build:
6+
context: ..
7+
dockerfile: docker/Dockerfile
8+
target: fuhon-node
9+
image: fuhon-node:develop-build
10+
ports:
11+
- "1234:1234"
12+
volumes:
13+
- ./interopnet:/tmp/fuhon
14+
fuhon-miner:
15+
build:
16+
context: ..
17+
dockerfile: docker/Dockerfile
18+
target: fuhon-miner
19+
image: fuhon-miner:develop-build
20+
volumes:
21+
- ./interopnet:/tmp/fuhon
22+
depends_on:
23+
- fuhon-node

‎docker/docker-compose-mainnet.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "3.0"
2+
3+
services:
4+
fuhon-node:
5+
build:
6+
context: ..
7+
dockerfile: docker/Dockerfile
8+
target: fuhon-node
9+
image: fuhon-node:develop-build
10+
ports:
11+
- "1234:1234"
12+
volumes:
13+
- ./mainnet:/tmp/fuhon
14+
fuhon-miner:
15+
build:
16+
context: ..
17+
dockerfile: docker/Dockerfile
18+
target: fuhon-miner
19+
image: fuhon-miner:develop-build
20+
volumes:
21+
- ./mainnet:/tmp/fuhon
22+
depends_on:
23+
- fuhon-node

‎docker/interopnet/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fuhon-miner-repo
2+
fuhon-node-repo

‎docker/interopnet/fuhon-node.cfg

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# use interopnet profile, corresponds to "make interopnet" lotus target
2+
profile=interopnet
3+
4+
bootstrap=/dns4/bootstrap-0.interop.fildev.network/tcp/1347/p2p/12D3KooWLGPq9JL1xwL6gHok7HSNxtK1Q5kyfg4Hk69ifRPghn4i
5+
bootstrap=/dns4/bootstrap-1.interop.fildev.network/tcp/1347/p2p/12D3KooWFYS1f31zafv8mqqYu8U3hEqYvaZ6avWzYU3BmZdpyH3h
File renamed without changes.

‎docker/mainnet/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fuhon-miner-repo
2+
fuhon-node-repo

‎docker/mainnet/fuhon-node.cfg

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# use mainnet profile
2+
profile=mainnet
3+
4+
bootstrap=/dns4/bootstrap-0.mainnet.filops.net/tcp/1347/p2p/12D3KooWCVe8MmsEMes2FzgTpt9fXtmCY7wrq91GRiaC8PHSCCBj
5+
bootstrap=/dns4/bootstrap-1.mainnet.filops.net/tcp/1347/p2p/12D3KooWCwevHg1yLCvktf2nvLu7L9894mcrJR4MsBCcm4syShVc
6+
bootstrap=/dns4/bootstrap-2.mainnet.filops.net/tcp/1347/p2p/12D3KooWEWVwHGn2yR36gKLozmb4YjDJGerotAPGxmdWZx2nxMC4
7+
bootstrap=/dns4/bootstrap-3.mainnet.filops.net/tcp/1347/p2p/12D3KooWKhgq8c7NQ9iGjbyK7v7phXvG6492HQfiDaGHLHLQjk7R
8+
bootstrap=/dns4/bootstrap-4.mainnet.filops.net/tcp/1347/p2p/12D3KooWL6PsFNPhYftrJzGgF5U18hFoaVhfGk7xwzD8yVrHJ3Uc
9+
bootstrap=/dns4/bootstrap-5.mainnet.filops.net/tcp/1347/p2p/12D3KooWLFynvDQiUpXoHroV1YxKHhPJgysQGH2k3ZGwtWzR4dFH
10+
bootstrap=/dns4/bootstrap-6.mainnet.filops.net/tcp/1347/p2p/12D3KooWP5MwCiqdMETF9ub1P3MbCvQCcfconnYHbWg6sUJcDRQQ
11+
bootstrap=/dns4/bootstrap-7.mainnet.filops.net/tcp/1347/p2p/12D3KooWRs3aY1p3juFjPy8gPN95PEQChm2QKGUCAdcDCC4EBMKf
12+
bootstrap=/dns4/bootstrap-8.mainnet.filops.net/tcp/1347/p2p/12D3KooWScFR7385LTyR4zU1bYdzSiiAb5rnNABfVahPvVSzyTkR
13+
bootstrap=/dns4/lotus-bootstrap.ipfsforce.com/tcp/41778/p2p/12D3KooWGhufNmZHF3sv48aQeS13ng5XVJZ9E6qy2Ms4VzqeUsHk
14+
bootstrap=/dns4/bootstrap-0.starpool.in/tcp/12757/p2p/12D3KooWGHpBMeZbestVEWkfdnC9u7p6uFHXL1n7m1ZBqsEmiUzz
15+
bootstrap=/dns4/bootstrap-1.starpool.in/tcp/12757/p2p/12D3KooWQZrGH1PxSNZPum99M1zNvjNFM33d1AAu5DcvdHptuU7u
16+
bootstrap=/dns4/node.glif.io/tcp/1235/p2p/12D3KooWBF8cpp65hp2u9LK5mh19x67ftAam84z9LsfaquTDSBpt
17+
bootstrap=/dns4/bootstrap-0.ipfsmain.cn/tcp/34721/p2p/12D3KooWQnwEGNqcM2nAcPtRR9rAX8Hrg4k9kJLCHoTR5chJfz6d
18+
bootstrap=/dns4/bootstrap-1.ipfsmain.cn/tcp/34723/p2p/12D3KooWMKxMkD5DMpSWsW7dBddKxKT7L2GgbNuckz9otxvkvByP
File renamed without changes.

‎docker/miner_entrypoint.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# if first arg looks like a flag, assume we want to run fuhon-miner
6+
if [ "${1:0:1}" = '-' ]; then
7+
set -- fuhon-miner "$@"
8+
fi
9+
10+
exec "$@"

‎docker/node_entrypoint.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# if first arg looks like a flag, assume we want to run fuhon-node
6+
if [ "${1:0:1}" = '-' ]; then
7+
set -- fuhon-node "$@"
8+
fi
9+
10+
exec "$@"

0 commit comments

Comments
 (0)
Please sign in to comment.