Skip to content

Commit b04fdb1

Browse files
committed
feat: add Ubuntu chiselled javascript template
1 parent 774cf40 commit b04fdb1

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

javascript/Dockerfile

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,64 @@
66
# If any needed dependencies rely on native binaries, you must use
77
# a riscv64 image such as cartesi/node:20-jammy for the build stage,
88
# 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
1010

1111
WORKDIR /opt/cartesi/dapp
1212
COPY . .
1313
RUN yarn install && yarn build
1414

15-
# runtime stage: produces final image that will be executed
15+
# chisel stage: produces final image that will be executed
1616

1717
# Here the image's platform MUST be linux/riscv64.
1818
# Give preference to small base images, which lead to better start-up
1919
# 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
2123

2224
ARG MACHINE_EMULATOR_TOOLS_VERSION=0.14.1
2325
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
2627

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
2947

30-
ARG DEBIAN_FRONTEND=noninteractive
3148
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
3857
EOF
3958

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
4063
ENV PATH="/opt/cartesi/bin:${PATH}"
41-
4264
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
4567
ENV ROLLUP_HTTP_SERVER_URL="http://127.0.0.1:5004"
46-
4768
ENTRYPOINT ["rollup-init"]
4869
CMD ["node", "index.js"]

0 commit comments

Comments
 (0)