From 891f792c77b33e14403e82551f51efc6e6ff6db1 Mon Sep 17 00:00:00 2001 From: MasterPtato Date: Tue, 16 Sep 2025 13:29:57 -0700 Subject: [PATCH] fix(ci): build frontend on release ci --- .github/workflows/release.yaml | 4 ++++ docker/engine/linux-aarch64.Dockerfile | 24 +++++++++++++++++++++++- docker/engine/linux-x86_64.Dockerfile | 23 ++++++++++++++++++++++- docker/engine/macos-aarch64.Dockerfile | 24 ++++++++++++++++++++++-- docker/engine/macos-x86_64.Dockerfile | 24 ++++++++++++++++++++++-- docker/engine/windows.Dockerfile | 23 ++++++++++++++++++++++- docker/universal/Dockerfile | 10 +++++++--- 7 files changed, 122 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f65e8d8c31..b08f53a08f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -191,6 +191,8 @@ jobs: file: docker/universal/Dockerfile target: engine-full platforms: ${{ matrix.platform }} + build-args: | + BUILD_FRONTEND=true # secrets: | # fontawesome_package_token=${{ secrets.FONTAWESOME_PACKAGE_TOKEN }} # secret-files: | @@ -205,6 +207,8 @@ jobs: file: docker/universal/Dockerfile target: engine-slim platforms: ${{ matrix.platform }} + build-args: | + BUILD_FRONTEND=true # secrets: | # fontawesome_package_token=${{ secrets.FONTAWESOME_PACKAGE_TOKEN }} # secret-files: | diff --git a/docker/engine/linux-aarch64.Dockerfile b/docker/engine/linux-aarch64.Dockerfile index b73dad2142..4ba790a6a9 100644 --- a/docker/engine/linux-aarch64.Dockerfile +++ b/docker/engine/linux-aarch64.Dockerfile @@ -1,5 +1,9 @@ # syntax=docker/dockerfile:1.4 FROM rust:1.88.0 AS base + +ARG BUILD_FRONTEND=true +ARG VITE_APP_API_URL + # Install dependencies RUN apt-get update && apt-get install -y \ musl-tools \ @@ -13,12 +17,19 @@ RUN apt-get update && apt-get install -y \ ca-certificates \ g++ \ g++-multilib \ - git-lfs && \ + git-lfs \ + curl && \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt-get install -y nodejs && \ + corepack enable && \ rm -rf /var/lib/apt/lists/* && \ wget -q https://github.com/cross-tools/musl-cross/releases/download/20250815/aarch64-unknown-linux-musl.tar.xz && \ tar -xzf aarch64-unknown-linux-musl.tgz -C /opt/ && \ rm aarch64-unknown-linux-musl.tgz +# Disable interactive prompt +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 + # Install musl targets RUN rustup target add aarch64-unknown-linux-musl @@ -60,6 +71,17 @@ ENV OPENSSL_DIR=/musl-aarch64 \ # Copy the source code COPY . . +# Build frontend +RUN if [ "$BUILD_FRONTEND" = "true" ]; then \ + (cd sdks/typescript/api-full && pnpm install && pnpm run build) && \ + (cd frontend && pnpm install && \ + if [ -n "$VITE_APP_API_URL" ]; then \ + VITE_APP_API_URL="${VITE_APP_API_URL}" pnpm run build:engine; \ + else \ + pnpm run build:engine; \ + fi); \ + fi + # Build for Linux with musl (static binary) - aarch64 RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ diff --git a/docker/engine/linux-x86_64.Dockerfile b/docker/engine/linux-x86_64.Dockerfile index 206bdfbc71..9a5c382534 100644 --- a/docker/engine/linux-x86_64.Dockerfile +++ b/docker/engine/linux-x86_64.Dockerfile @@ -1,6 +1,9 @@ # syntax=docker/dockerfile:1.4 FROM rust:1.88.0 AS base +ARG BUILD_FRONTEND=true +ARG VITE_APP_API_URL + # Install dependencies RUN apt-get update && apt-get install -y \ musl-tools \ @@ -14,12 +17,19 @@ RUN apt-get update && apt-get install -y \ ca-certificates \ g++ \ g++-multilib \ - git-lfs && \ + git-lfs \ + curl && \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt-get install -y nodejs && \ + corepack enable && \ rm -rf /var/lib/apt/lists/* && \ wget -q https://github.com/cross-tools/musl-cross/releases/latest/download/x86_64-unknown-linux-musl.tar.xz && \ tar -xf x86_64-unknown-linux-musl.tar.xz -C /opt/ && \ rm x86_64-unknown-linux-musl.tar.xz +# Disable interactive prompt +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 + # Install musl targets RUN rustup target add x86_64-unknown-linux-musl @@ -61,6 +71,17 @@ ENV OPENSSL_DIR=/musl \ # Copy the source code COPY . . +# Build frontend +RUN if [ "$BUILD_FRONTEND" = "true" ]; then \ + (cd sdks/typescript/api-full && pnpm install && pnpm run build) && \ + (cd frontend && pnpm install && \ + if [ -n "$VITE_APP_API_URL" ]; then \ + VITE_APP_API_URL="${VITE_APP_API_URL}" pnpm run build:engine; \ + else \ + pnpm run build:engine; \ + fi); \ + fi + # Build for Linux with musl (static binary) - x86_64 RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ diff --git a/docker/engine/macos-aarch64.Dockerfile b/docker/engine/macos-aarch64.Dockerfile index 8c01e02e4a..e3bde5a4b8 100644 --- a/docker/engine/macos-aarch64.Dockerfile +++ b/docker/engine/macos-aarch64.Dockerfile @@ -1,6 +1,9 @@ # syntax=docker/dockerfile:1.4 FROM rust:1.88.0 AS base +ARG BUILD_FRONTEND=true +ARG VITE_APP_API_URL + # Install dependencies RUN apt-get update && apt-get install -y \ git-lfs \ @@ -11,8 +14,11 @@ RUN apt-get update && apt-get install -y \ libxml2-dev \ wget \ xz-utils \ - curl \ - && rm -rf /var/lib/apt/lists/* + curl && \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt-get install -y nodejs && \ + corepack enable && \ + rm -rf /var/lib/apt/lists/* # Install osxcross RUN git config --global --add safe.directory '*' && \ @@ -25,6 +31,9 @@ RUN git config --global --add safe.directory '*' && \ # Add osxcross to PATH ENV PATH="/root/osxcross/target/bin:$PATH" +# Disable interactive prompt +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 + # Tell Clang/bindgen to use the macOS SDK, and nudge Clang to prefer osxcross binutils. ENV OSXCROSS_SDK=MacOSX11.3.sdk \ SDKROOT=/root/osxcross/target/SDK/MacOSX11.3.sdk \ @@ -61,6 +70,17 @@ ar = "aarch64-apple-darwin20.4-ar"\n\ # Copy the source code COPY . . +# Build frontend +RUN if [ "$BUILD_FRONTEND" = "true" ]; then \ + (cd sdks/typescript/api-full && pnpm install && pnpm run build) && \ + (cd frontend && pnpm install && \ + if [ -n "$VITE_APP_API_URL" ]; then \ + VITE_APP_API_URL="${VITE_APP_API_URL}" pnpm run build:engine; \ + else \ + pnpm run build:engine; \ + fi); \ + fi + # Build for ARM64 macOS RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ diff --git a/docker/engine/macos-x86_64.Dockerfile b/docker/engine/macos-x86_64.Dockerfile index 6911656199..2e249121f8 100644 --- a/docker/engine/macos-x86_64.Dockerfile +++ b/docker/engine/macos-x86_64.Dockerfile @@ -1,6 +1,9 @@ # syntax=docker/dockerfile:1.4 FROM rust:1.88.0 AS base +ARG BUILD_FRONTEND=true +ARG VITE_APP_API_URL + # Install dependencies RUN apt-get update && apt-get install -y \ git-lfs \ @@ -11,8 +14,11 @@ RUN apt-get update && apt-get install -y \ libxml2-dev \ wget \ xz-utils \ - curl \ - && rm -rf /var/lib/apt/lists/* + curl && \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt-get install -y nodejs && \ + corepack enable && \ + rm -rf /var/lib/apt/lists/* # Install osxcross RUN git config --global --add safe.directory '*' && \ @@ -25,6 +31,9 @@ RUN git config --global --add safe.directory '*' && \ # Add osxcross to PATH ENV PATH="/root/osxcross/target/bin:$PATH" +# Disable interactive prompt +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 + # Tell Clang/bindgen to use the macOS SDK, and nudge Clang to prefer osxcross binutils. ENV OSXCROSS_SDK=MacOSX11.3.sdk \ SDKROOT=/root/osxcross/target/SDK/MacOSX11.3.sdk \ @@ -61,6 +70,17 @@ ar = "x86_64-apple-darwin20.4-ar"\n\ # Copy the source code COPY . . +# Build frontend +RUN if [ "$BUILD_FRONTEND" = "true" ]; then \ + (cd sdks/typescript/api-full && pnpm install && pnpm run build) && \ + (cd frontend && pnpm install && \ + if [ -n "$VITE_APP_API_URL" ]; then \ + VITE_APP_API_URL="${VITE_APP_API_URL}" pnpm run build:engine; \ + else \ + pnpm run build:engine; \ + fi); \ + fi + # Build for x86_64 macOS RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ diff --git a/docker/engine/windows.Dockerfile b/docker/engine/windows.Dockerfile index 5e798fd476..5080593ba0 100644 --- a/docker/engine/windows.Dockerfile +++ b/docker/engine/windows.Dockerfile @@ -1,6 +1,9 @@ # syntax=docker/dockerfile:1.4 FROM rust:1.88.0 +ARG BUILD_FRONTEND=true +ARG VITE_APP_API_URL + # Install dependencies RUN apt-get update && apt-get install -y \ llvm-14-dev \ @@ -12,12 +15,19 @@ RUN apt-get update && apt-get install -y \ g++-mingw-w64-x86-64 \ binutils-mingw-w64-x86-64 \ ca-certificates \ - && rm -rf /var/lib/apt/lists/* + curl && \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt-get install -y nodejs && \ + corepack enable && \ + rm -rf /var/lib/apt/lists/* # Switch MinGW-w64 to the POSIX threading model toolchain RUN update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix && \ update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix +# Disable interactive prompt +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 + # Install target RUN rustup target add x86_64-pc-windows-gnu @@ -48,6 +58,17 @@ WORKDIR /build # Copy the source code COPY . . +# Build frontend +RUN if [ "$BUILD_FRONTEND" = "true" ]; then \ + (cd sdks/typescript/api-full && pnpm install && pnpm run build) && \ + (cd frontend && pnpm install && \ + if [ -n "$VITE_APP_API_URL" ]; then \ + VITE_APP_API_URL="${VITE_APP_API_URL}" pnpm run build:engine; \ + else \ + pnpm run build:engine; \ + fi); \ + fi + # Build for Windows RUN --mount=type=cache,target=/usr/local/cargo/registry \ --mount=type=cache,target=/usr/local/cargo/git \ diff --git a/docker/universal/Dockerfile b/docker/universal/Dockerfile index bc30f1396f..e07ea87137 100644 --- a/docker/universal/Dockerfile +++ b/docker/universal/Dockerfile @@ -8,6 +8,7 @@ FROM --platform=linux/amd64 rust:1.88.0-bookworm AS builder ARG TARGETARCH ARG BUILD_FRONTEND=false +ARG VITE_APP_API_URL ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update -y && \ @@ -38,8 +39,6 @@ RUN apt-get update -y && \ # Disable interactive prompt ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 -ENV RIVET_SKIP_BUILD_TS_SDK=1 - # Pull via Git CLI to improve reliability in CI ENV CARGO_NET_GIT_FETCH_WITH_CLI=true @@ -50,7 +49,12 @@ COPY . . # Build frontend RUN if [ "$BUILD_FRONTEND" = "true" ]; then \ (cd sdks/typescript/api-full && pnpm install && pnpm run build) && \ - (cd frontend && pnpm install && pnpm run build); \ + (cd frontend && pnpm install && \ + if [ -n "$VITE_APP_API_URL" ]; then \ + VITE_APP_API_URL="${VITE_APP_API_URL}" pnpm run build:engine; \ + else \ + pnpm run build:engine; \ + fi); \ fi # Build and copy all binaries from target directory into an empty image (it is not