|
6 | 6 | # If any needed dependencies rely on native binaries, you must use
|
7 | 7 | # a riscv64 image such as cartesi/node:20-jammy for the build stage,
|
8 | 8 | # to ensure that the appropriate binaries will be generated.
|
9 |
| -FROM node:20.8.0-bookworm as build-stage |
| 9 | +FROM --platform=amd64 node:18-bookworm as build-stage |
10 | 10 |
|
11 | 11 | WORKDIR /opt/cartesi/dapp
|
12 | 12 | COPY . .
|
13 | 13 | RUN yarn install && yarn build
|
14 | 14 |
|
15 |
| -# runtime stage: produces final image that will be executed |
| 15 | +# chisel stage: produces final image that will be executed |
16 | 16 |
|
17 | 17 | # Here the image's platform MUST be linux/riscv64.
|
18 | 18 | # Give preference to small base images, which lead to better start-up
|
19 | 19 | # performance when loading the Cartesi Machine.
|
20 |
| -FROM --platform=linux/riscv64 cartesi/node:20.8.0-jammy-slim |
| 20 | +FROM riscv64/ubuntu:22.04 as chisel |
| 21 | + |
| 22 | +WORKDIR /rootfs |
21 | 23 |
|
22 | 24 | ARG MACHINE_EMULATOR_TOOLS_VERSION=0.14.1
|
23 | 25 | ADD https://github.com/cartesi/machine-emulator-tools/releases/download/v${MACHINE_EMULATOR_TOOLS_VERSION}/machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb /
|
24 |
| -RUN dpkg -i /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb \ |
25 |
| - && rm /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb |
| 26 | +RUN dpkg -x /machine-emulator-tools-v${MACHINE_EMULATOR_TOOLS_VERSION}.deb /rootfs |
26 | 27 |
|
27 |
| -LABEL io.cartesi.rollups.sdk_version=0.6.0 |
28 |
| -LABEL io.cartesi.rollups.ram_size=128Mi |
| 28 | +# Get chisel binary |
| 29 | +ARG CHISEL_VERSION=0.9.1 |
| 30 | +ADD "https://github.com/canonical/chisel/releases/download/v${CHISEL_VERSION}/chisel_v${CHISEL_VERSION}_linux_riscv64.tar.gz" chisel.tar.gz |
| 31 | +RUN tar -xvf chisel.tar.gz -C /usr/bin/ |
| 32 | + |
| 33 | +# Extract nodejs dependencies into the chiselled filesystem |
| 34 | +ADD https://github.com/cartesi/chisel-releases.git#6c3f741b1bb22c49eba81a338195a40ad3239a78 /ubuntu-24.04-riscv64 |
| 35 | +RUN chisel cut \ |
| 36 | + --release /ubuntu-24.04-riscv64 \ |
| 37 | + --root /rootfs \ |
| 38 | + --arch=riscv64 \ |
| 39 | + # base rootfs dependencies |
| 40 | + base-files_base \ |
| 41 | + base-passwd_data \ |
| 42 | + # machine-emulator-tools dependencies |
| 43 | + busybox-static_bins \ |
| 44 | + libgcc-s1_libs \ |
| 45 | + # nodejs |
| 46 | + nodejs_bins |
29 | 47 |
|
30 |
| -ARG DEBIAN_FRONTEND=noninteractive |
31 | 48 | RUN <<EOF
|
32 |
| -set -e |
33 |
| -apt-get update |
34 |
| -apt-get install -y --no-install-recommends \ |
35 |
| - busybox-static=1:1.30.1-7ubuntu3 |
36 |
| -rm -rf /var/lib/apt/lists/* /var/log/* /var/cache/* |
37 |
| -useradd --create-home --user-group dapp |
| 49 | + set -e |
| 50 | + ln -s /usr/bin/busybox bin/sh |
| 51 | + mkdir -p proc sys dev run/cruntime mnt |
| 52 | + echo "dapp:x:1000:1000::/home/dapp:/bin/sh" >> etc/passwd |
| 53 | + echo "dapp:x:1000:" >> etc/group |
| 54 | + mkdir home/dapp |
| 55 | + chown 1000:1000 home/dapp |
| 56 | + sed -i '/^root/s/bash/sh/g' etc/passwd |
38 | 57 | EOF
|
39 | 58 |
|
| 59 | +# runtime stage: final image |
| 60 | +FROM scratch |
| 61 | +LABEL io.cartesi.rollups.sdk_version=0.6.0 |
| 62 | +LABEL io.cartesi.rollups.ram_size=128Mi |
40 | 63 | ENV PATH="/opt/cartesi/bin:${PATH}"
|
41 |
| - |
42 | 64 | WORKDIR /opt/cartesi/dapp
|
43 |
| -COPY --from=build-stage /opt/cartesi/dapp/dist . |
44 |
| - |
| 65 | +COPY --from=chisel /rootfs / |
| 66 | +COPY --from=build-stage /opt/cartesi/dapp/dist /opt/cartesi/dapp |
45 | 67 | ENV ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004"
|
46 |
| - |
47 | 68 | ENTRYPOINT ["rollup-init"]
|
48 | 69 | CMD ["node", "index.js"]
|
0 commit comments