Skip to content

Commit 1898463

Browse files
committed
build: dockerification
This adds Dockerfiles for packaging: 1. sugondat/shim 2. sugondat/node 3. demo/rollkit 4. demo/sovereign Also, because risc0 toolchain is quite annoying to build, this also adds another Dockerfile for building it. Sovereign demo depends on that.
1 parent b4b8fff commit 1898463

File tree

10 files changed

+315
-37
lines changed

10 files changed

+315
-37
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
/target/

demo/rollkit/docker/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM golang:1.21 as builder
2+
3+
LABEL org.opencontainers.image.source=https://github.com/thrumdev/blobs
4+
5+
RUN \
6+
apt-get update && \
7+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
8+
ca-certificates \
9+
curl
10+
11+
# Install ignite CLI
12+
RUN curl https://get.ignite.com/[email protected]! | bash
13+
14+
# it seems that `go work` is broken in docker. Let's just copy the sugondat package.
15+
COPY ./demo/rollkit /demo-rollkit
16+
COPY ./adapters/rollkit /demo-rollkit/sugondat
17+
# Patch the source file
18+
RUN sed -i 's/\"sugondat\"/\"gm\/sugondat\"/' /demo-rollkit/cmd/gmd/cmd/root.go
19+
RUN rm /demo-rollkit/sugondat/go.*
20+
WORKDIR /demo-rollkit
21+
22+
RUN --mount=type=cache,target=/go/pkg \
23+
--mount=type=cache,target=/root/.cache/go-build \
24+
go mod download && \
25+
go mod verify && \
26+
ignite chain build
27+
28+
FROM golang:1.21 AS prod
29+
30+
COPY --from=builder /go/bin/gmd /usr/local/bin/gmd
31+
COPY ./demo/rollkit/init-local.sh /root/init-local.sh
32+
WORKDIR /root
33+
ENTRYPOINT /usr/local/bin/gmd

demo/sovereign/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
docker/
2+
!docker/rollup_config.docker.toml

demo/sovereign/docker/Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
FROM ghcr.io/thrumdev/risczero:latest as risczero
2+
3+
FROM ubuntu:20.04 as builder
4+
5+
LABEL org.opencontainers.image.source=https://github.com/thrumdev/blobs
6+
7+
ARG RUSTC_VERSION=nightly-2023-10-16
8+
9+
ENV CARGO_INCREMENTAL=0
10+
ENV CARGO_HOME=/cargo
11+
ENV CARGO_TARGET_DIR=/cargo_target
12+
ENV RUSTFLAGS="-Cdebuginfo=0"
13+
ENV RUSTUP_HOME=/rustup
14+
15+
RUN mkdir -p /cargo && \
16+
mkdir -p /cargo_target && \
17+
mkdir -p /rustup
18+
19+
RUN \
20+
apt-get update && \
21+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
22+
ca-certificates \
23+
protobuf-compiler \
24+
curl \
25+
git \
26+
llvm \
27+
clang \
28+
cmake \
29+
make \
30+
libssl-dev \
31+
pkg-config
32+
33+
RUN \
34+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION
35+
36+
COPY --from=risczero $CARGO_HOME/bin/cargo-risczero $CARGO_HOME/bin/cargo-risczero
37+
COPY --from=risczero $CARGO_HOME/bin/r0vm $CARGO_HOME/bin/r0vm
38+
COPY --from=risczero /rustup/toolchains/risc0 $RUSTUP_HOME/toolchains/risc0
39+
40+
WORKDIR /sugondat
41+
COPY . /sugondat
42+
43+
ENV CONSTANTS_MANIFEST=/sugondat/demo/sovereign/constants.json
44+
RUN \
45+
--mount=type=cache,target=/cargo/git \
46+
--mount=type=cache,target=/cargo/registry \
47+
--mount=type=cache,target=/cargo_target \
48+
cd demo/sovereign \
49+
&& $CARGO_HOME/bin/cargo build --release --locked \
50+
&& cp $CARGO_TARGET_DIR/release/sov-demo-rollup /usr/bin/sov-demo-rollup \
51+
&& cp $CARGO_TARGET_DIR/release/sov-cli /usr/bin/sov-cli
52+
53+
FROM ubuntu:20.04 as prod
54+
55+
RUN \
56+
apt-get update && \
57+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
58+
libssl-dev \
59+
pkg-config
60+
61+
ENV TINI_VERSION v0.19.0
62+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
63+
RUN chmod +x /tini
64+
65+
COPY --from=builder /usr/bin/sov-demo-rollup /usr/bin/sov-demo-rollup
66+
COPY --from=builder /usr/bin/sov-cli /usr/bin/sov-cli
67+
68+
COPY ./demo/sovereign /sugondat/demo/sovereign
69+
COPY ./demo/sovereign/docker/rollup_config.docker.toml /sugondat/demo/sovereign/demo-rollup/rollup_config.toml
70+
WORKDIR /sugondat/demo/sovereign/demo-rollup
71+
72+
EXPOSE 12345
73+
74+
ENTRYPOINT ["/tini", "--", "/usr/bin/sov-demo-rollup"]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[da]
2+
sugondat_rpc = "ws://localhost:10995/"
3+
4+
5+
[storage]
6+
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
7+
path = "/demo_data"
8+
9+
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
10+
# any blocks before this height
11+
[runner]
12+
start_height = 1
13+
14+
[runner.rpc_config]
15+
# the host and port to bind the rpc server for
16+
bind_host = "0.0.0.0"
17+
bind_port = 12345

docker/risczero.Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM ubuntu:20.04 as builder
2+
3+
LABEL org.opencontainers.image.source=https://github.com/thrumdev/blobs
4+
5+
ARG RUSTC_VERSION=nightly-2023-10-16
6+
7+
ENV CARGO_INCREMENTAL=0
8+
ENV CARGO_HOME=/cargo
9+
ENV CARGO_TARGET_DIR=/cargo_target
10+
ENV RUSTFLAGS=""
11+
ENV RUSTUP_HOME=/rustup
12+
13+
RUN mkdir -p /cargo && \
14+
mkdir -p /cargo_target && \
15+
mkdir -p /rustup
16+
17+
RUN \
18+
apt-get update && \
19+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
20+
ca-certificates \
21+
protobuf-compiler \
22+
curl \
23+
git \
24+
llvm \
25+
clang \
26+
cmake \
27+
make \
28+
libssl-dev \
29+
pkg-config \
30+
ninja-build \
31+
python3
32+
33+
RUN \
34+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION
35+
36+
RUN curl \
37+
-L --proto '=https' --tlsv1.2 -sSf \
38+
https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh \
39+
| bash
40+
41+
# Mount caches because it will build on unsupported platforms.
42+
RUN \
43+
--mount=type=cache,target=/cargo/git \
44+
--mount=type=cache,target=/cargo/registry \
45+
--mount=type=cache,target=/cargo_target \
46+
$CARGO_HOME/bin/cargo binstall --no-confirm --no-symlinks cargo-risczero
47+
48+
RUN \
49+
apt-get update && \
50+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends python3 && \
51+
ln -s /usr/bin/python3 /usr/bin/python
52+
53+
RUN \
54+
--mount=type=cache,target=/cargo/git \
55+
--mount=type=cache,target=/cargo/registry \
56+
--mount=type=cache,target=/cargo_target \
57+
--mount=type=cache,target=/root/.risc0/rust \
58+
$CARGO_HOME/bin/cargo risczero install \
59+
|| ( \
60+
$CARGO_HOME/bin/cargo risczero build-toolchain \
61+
&& rm /rustup/toolchains/risc0 \
62+
&& cp -r /root/.risc0/rust/build/aarch64-unknown-linux-gnu/stage2 /rustup/toolchains/risc0 \
63+
)

sugondat/chain/.dockerignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,3 @@
22
**/target/
33
**/*.txt
44
**/*.md
5-
/docker/
6-
!/target/release/polkadot-collator
7-
8-
# dotfiles in the repo root
9-
/.*

sugondat/chain/Containerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

sugondat/chain/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
FROM ubuntu:20.04 as builder
2+
3+
LABEL org.opencontainers.image.source=https://github.com/thrumdev/blobs
4+
5+
ARG RUSTC_VERSION=nightly-2023-10-16
6+
7+
ENV CARGO_INCREMENTAL=0
8+
ENV CARGO_HOME=/cargo
9+
ENV CARGO_TARGET_DIR=/cargo_target
10+
ENV RUSTFLAGS=""
11+
ENV RUSTUP_HOME=/rustup
12+
ENV WASM_BUILD_WORKSPACE_HINT=/sugondat
13+
# Force fetching git deps with git CLI instead of libgit2 to workaround build failures.
14+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
15+
16+
RUN mkdir -p /cargo && \
17+
mkdir -p /cargo_target && \
18+
mkdir -p /rustup
19+
20+
RUN \
21+
apt-get update && \
22+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
23+
ca-certificates \
24+
protobuf-compiler \
25+
curl \
26+
git \
27+
llvm \
28+
clang \
29+
cmake \
30+
make
31+
32+
RUN \
33+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION
34+
RUN $CARGO_HOME/bin/rustup target add wasm32-unknown-unknown
35+
36+
WORKDIR /sugondat
37+
COPY . /sugondat
38+
39+
FROM builder AS builder-release
40+
41+
RUN --mount=type=cache,target=/cargo/git \
42+
--mount=type=cache,target=/cargo/registry \
43+
--mount=type=cache,target=/cargo_target \
44+
$CARGO_HOME/bin/cargo build --locked --release -p sugondat-node && \
45+
cp /cargo_target/release/sugondat-node /usr/bin/sugondat-node
46+
47+
FROM ubuntu:20.04
48+
49+
ENV TINI_VERSION v0.19.0
50+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
51+
RUN chmod +x /tini
52+
53+
RUN \
54+
apt-get update && \
55+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
56+
ca-certificates \
57+
curl
58+
59+
COPY --from=builder-release /usr/bin/sugondat-node /usr/bin/sugondat-node
60+
61+
ENTRYPOINT ["/tini", "--", "/usr/bin/sugondat-node"]

sugondat/shim/Dockerfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
FROM ubuntu:20.04 as builder
2+
3+
LABEL org.opencontainers.image.source=https://github.com/thrumdev/blobs
4+
5+
ARG RUSTC_VERSION=nightly-2023-10-16
6+
7+
ENV CARGO_INCREMENTAL=0
8+
ENV CARGO_HOME=/cargo
9+
ENV CARGO_TARGET_DIR=/cargo_target
10+
ENV RUSTFLAGS=""
11+
ENV RUSTUP_HOME=/rustup
12+
ENV WASM_BUILD_WORKSPACE_HINT=/sugondat
13+
# Force fetching git deps with git CLI instead of libgit2 to workaround build failures.
14+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
15+
16+
RUN mkdir -p /cargo && \
17+
mkdir -p /cargo_target && \
18+
mkdir -p /rustup
19+
20+
RUN \
21+
apt-get update && \
22+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
23+
ca-certificates \
24+
protobuf-compiler \
25+
curl \
26+
git \
27+
llvm \
28+
clang \
29+
cmake \
30+
make
31+
32+
RUN \
33+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION
34+
35+
WORKDIR /sugondat
36+
COPY . /sugondat
37+
38+
FROM builder AS builder-release
39+
40+
RUN --mount=type=cache,target=/cargo/git \
41+
--mount=type=cache,target=/cargo/registry \
42+
--mount=type=cache,target=/cargo_target \
43+
$CARGO_HOME/bin/cargo build --locked --release -p sugondat-shim && \
44+
cp /cargo_target/release/sugondat-shim /usr/bin/sugondat-shim
45+
46+
FROM ubuntu:20.04
47+
48+
ENV TINI_VERSION v0.19.0
49+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
50+
RUN chmod +x /tini
51+
52+
RUN \
53+
apt-get update && \
54+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
55+
ca-certificates \
56+
curl
57+
58+
COPY --from=builder-release /usr/bin/sugondat-shim /usr/bin/sugondat-shim
59+
60+
EXPOSE 10995
61+
62+
ENTRYPOINT ["/tini", "--", "/usr/bin/sugondat-shim"]
63+
CMD ["serve", "-p", "10995"]

0 commit comments

Comments
 (0)