datahaven/test/docker/datahaven-node-local.dockerfile
Facundo Farall a86791ec1c
perf(CLI): Add option to use local Docker build in CLI for faster iteration (#77)
In this PR:
1. Add new `datahaven-node-local.dockerfile` for building a local image
with the locally built DataHaven Node binary. This severely improves
iteration speed on running `bun cli` if there are changes in the DH
node. Previously, it relied on the published dockerfile, which builds
the Cargo project inside of it, taking +20m even with no changes.
2. Building this local dockerfile is integrated to the CLI, which now
also asks if the user wants to rebuild the local docker image of the DH
node.
3. A new script `cargo-crossbuild` is added, to be able to build the
DataHaven node Cargo project both from Mac and Linux, with the target
being `x86_64-unknown-linux-gnu`. For building from Mac, it uses `cargo
zigbuild`, so `zig` is now a dependency. Building for this target is
needed because the docker image is an Ubuntu image, so it will need to
run a linux binary.
4. Added `zig` as dependency in docs.
5. CI still uses the docker image built by the CI itself, which builds
the Cargo project inside of it. The CI can take advantage of caching for
this.
2025-05-16 18:04:40 -03:00

40 lines
No EOL
1.3 KiB
Docker

# DATAHAVEN_NODE DOCKERFILE
#
# This Dockerfile expects to have the binary already built.
# So it just copies the binary into the image and runs it.
#
# This is done to speed up iterating while running the E2E CLI.
#
# Requires to run from /test folder and to copy the binary in the build folder
FROM ubuntu:noble
LABEL version="0.1.0"
LABEL description="DataHaven Node Local Build"
ENV RUST_BACKTRACE=1
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates curl sudo librocksdb-dev libpq-dev && \
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete && \
useradd -m -u 1337 -U -s /bin/sh -d /datahaven datahaven && \
mkdir -p /data /datahaven/.local/share /specs /storage && \
chown -R datahaven:datahaven /data && \
ln -s /data /datahaven/.local/share/datahaven-node && \
echo "datahaven ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
chmod -R 777 /storage /data
USER datahaven
COPY --chown=datahaven:datahaven ./operator/target/x86_64-unknown-linux-gnu/release/datahaven-node /usr/local/bin/datahaven-node
RUN chmod uog+x /usr/local/bin/datahaven-node
EXPOSE 9333 9944 30333 30334 9615
VOLUME ["/data"]
ENTRYPOINT ["datahaven-node"]
CMD ["--tmp"]