From 617dfb0c9d25b057ea055550646b0db5fed2a3c2 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Tue, 20 Jan 2026 14:08:45 +0100 Subject: [PATCH] feat: add Dockerfile for app to deploy preview --- app/Dockerfile | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 app/Dockerfile diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 0000000..d171c39 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,70 @@ +# --- Builder Stage --- +FROM node:24-alpine AS builder + +# Install system dependencies +RUN apk add --no-cache curl g++ gcc make libc-dev + +# Optimized Rust Installation +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal \ + && rustup target add wasm32-unknown-unknown + +WORKDIR /app + +# 1. Copy Manifests for Caching +# Copy root manifests +COPY pnpm-lock.yaml pnpm-workspace.yaml package.json Cargo.lock Cargo.toml ./ + +# Copy all sub-package package.json and Cargo.toml files to cache dependency installation +# This "wildcard" approach in Alpine/sh can be tricky, so we copy the specific directories +# that define the workspace structure. +COPY packages/ ./packages/ +COPY nodes/ ./nodes/ +COPY app/package.json ./app/ + +# 2. Install & Cache Dependencies +# We mount the Cargo registry (crates) and the target folder (compiled artifacts) +RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \ + --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/app/target \ + npm install -g pnpm@latest && \ + pnpm install --frozen-lockfile + +# 3. Full Source Copy & Build +COPY . . + +# We apply the cache mounts again during the build. +# pnpm build:nodes will now find its Rust artifacts in /app/target from the previous run. +RUN --mount=type=cache,id=pnpm-store,target=/root/.local/share/pnpm/store \ + --mount=type=cache,target=/usr/local/cargo/registry \ + --mount=type=cache,target=/app/target \ + pnpm build:nodes && \ + pnpm --filter @nodarium/app... build + +# --- Static Runner Stage --- +FROM nginx:alpine AS runner + +# Remove default nginx config +RUN rm /etc/nginx/conf.d/default.conf + +# Minimal static file config +COPY <