mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## Changes - New CI file for making Docker Prod images - Changed E2E tests use an image built from a local dockerfile - Some cargo build options to make it quicker - Fix the cache hit rate - added `tsgo` preview to the project 😎 - Can be invoked with `bun tsgo` to typecheck - Install in IDE [VSCode](https://code.visualstudio.com/docs/configure/extensions/extension-marketplace) & [Zed](https://github.com/zed-extensions/tsgo) for super-fast inline typechecking (as you type basically) ## Context This PR attempts to make the frankly unacceptable CI times better. This achieves that aim by making a crappy image for day-to-day usage and let the prod issue take ages since that will be infrequently used. The reason why the original design didn't work for us is because: 1) we are using the free GH runners 2) when we goto baremetal runners we'll lose our rapid caching abilities which make using docker cheap. Also, we add `tsgo` support to improve devex. The improvement is astounding. ```sh hyperfine -n tsc "bun tsc --incremental false --extendedDiagnostics" -n tsgo "bun tsgo --incremental false --extendedDiagnostics" Benchmark 1: tsc Time (mean ± σ): 5.500 s ± 0.221 s [User: 8.939 s, System: 0.400 s] Range (min … max): 5.196 s … 5.845 s 10 runs Benchmark 2: tsgo Time (mean ± σ): 99.1 ms ± 8.4 ms [User: 392.8 ms, System: 54.1 ms] Range (min … max): 88.3 ms … 116.0 ms 29 runs Summary tsgo ran 55.48 ± 5.22 times faster than tsc ```
69 lines
No EOL
2.6 KiB
Docker
69 lines
No EOL
2.6 KiB
Docker
# --- Setup Build Environment ---
|
|
FROM docker.io/paritytech/ci-unified:bullseye-1.85.0 AS base
|
|
|
|
ARG MOLD_VERSION=2.39.0
|
|
ARG SCCACHE_VERSION=0.10.0
|
|
ARG FAST_RUNTIME=FALSE
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
xz-utils \
|
|
clang \
|
|
&& echo "Installing mold v${MOLD_VERSION}..." \
|
|
&& curl -Lo mold.tar.gz "https://github.com/rui314/mold/releases/download/v${MOLD_VERSION}/mold-${MOLD_VERSION}-x86_64-linux.tar.gz" \
|
|
&& tar -xf mold.tar.gz --strip-components=1 -C /usr/local \
|
|
&& rm mold.tar.gz \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& echo "Installing sccache v${SCCACHE_VERSION}..." \
|
|
&& curl -Lo sccache.tar.gz "https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" \
|
|
&& tar -xf sccache.tar.gz --strip-components=1 -C /usr/local/bin sccache-v${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache \
|
|
&& rm sccache.tar.gz
|
|
|
|
RUN cargo install cargo-chef --version 0.1.71 --locked
|
|
|
|
ENV RUSTC_WRAPPER=sccache \
|
|
SCCACHE_DIR=/usr/local/sccache \
|
|
SCCACHE_CACHE_SIZE=25G \
|
|
RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=/usr/local/bin/mold"
|
|
|
|
# --- Prepare build plan with cargo-chef ---
|
|
FROM base AS planner
|
|
WORKDIR /datahaven
|
|
COPY . .
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
|
|
|
# --- Build dependencies using cargo-chef ---
|
|
FROM base AS builder
|
|
WORKDIR /datahaven
|
|
COPY --from=planner /datahaven/recipe.json recipe.json
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,target=/usr/local/cargo/git \
|
|
--mount=type=cache,target=/usr/local/sccache,sharing=locked \
|
|
cargo chef cook --recipe-path recipe.json --release
|
|
COPY . .
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
--mount=type=cache,target=/usr/local/cargo/git \
|
|
--mount=type=cache,target=/usr/local/sccache,sharing=locked \
|
|
if [ "$FAST_RUNTIME" = "TRUE" ]; then \
|
|
cargo build --locked --release --features fast-runtime; \
|
|
else \
|
|
cargo build --locked --release; \
|
|
fi
|
|
|
|
# --- Create final lightweight runtime image ---
|
|
FROM docker.io/parity/base-bin:latest
|
|
COPY --from=builder /datahaven/target/release/datahaven-node /usr/local/bin
|
|
|
|
USER root
|
|
RUN useradd -m -u 1001 -U -s /bin/sh -d /datahaven datahaven && \
|
|
mkdir -p /data /datahaven/.local/share && \
|
|
chown -R datahaven:datahaven /data && \
|
|
ln -s /data /datahaven/.local/share/datahaven && \
|
|
/usr/local/bin/datahaven-node --version
|
|
|
|
USER datahaven
|
|
|
|
EXPOSE 30333 9933 9944 9615
|
|
VOLUME ["/data"]
|
|
|
|
ENTRYPOINT ["/usr/local/bin/datahaven-node"] |