Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ jobs:
push: true
platforms: linux/${{ matrix.arch }}
tags: |

${{ env.IMAGE }}:${{ steps.version.outputs.version }}-slim-${{ matrix.arch }}
${{ env.IMAGE }}:slim-${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=release-slim
cache-to: type=gha,mode=max,scope=release-slim

- name: Build and push full
uses: docker/build-push-action@v6
Expand All @@ -77,8 +78,9 @@ jobs:
tags: |
${{ env.IMAGE }}:${{ steps.version.outputs.version }}-full-${{ matrix.arch }}
${{ env.IMAGE }}:full-${{ matrix.arch }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=release-full
cache-to: type=gha,mode=max,scope=release-full


publish-manifests:
runs-on: ubuntu-latest
Expand Down
19 changes: 16 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.6
# ---- Builder stage ----
# Compiles the React frontend and the Rust binary with the frontend embedded.
FROM rust:bookworm AS builder
Expand All @@ -21,11 +22,20 @@ WORKDIR /build
# 1. Fetch and cache Rust dependencies.
# cargo fetch needs a valid target, so we create stubs that get replaced later.
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs && touch src/lib.rs && cargo fetch && rm -rf src
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/target \
mkdir src && echo "fn main() {}" > src/main.rs && touch src/lib.rs \
&& cargo build --release \
&& rm -rf src

# 2. Build the frontend.
COPY interface/package.json interface/
RUN --mount=type=cache,target=/root/.bun/install/cache \
cd interface && bun install
COPY interface/ interface/
RUN cd interface && bun install && bun add -d @rollup/rollup-linux-x64-gnu && bun run build
RUN --mount=type=cache,target=/root/.bun/install/cache \
cd interface && bun run build

# 3. Copy source and compile the real binary.
# build.rs runs the frontend build (already done above, node_modules present).
Expand All @@ -35,7 +45,10 @@ COPY build.rs ./
COPY prompts/ prompts/
COPY migrations/ migrations/
COPY src/ src/
RUN cargo build --release
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/build/target \
SPACEBOT_SKIP_FRONTEND_BUILD=1 cargo build --release

# ---- Slim stage ----
# Minimal runtime with just the binary. No browser.
Expand Down
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::process::Command;

fn main() {
if std::env::var("SPACEBOT_SKIP_FRONTEND_BUILD").is_ok() {
return;
}
// Re-run if interface source files change
println!("cargo:rerun-if-changed=interface/src/");
println!("cargo:rerun-if-changed=interface/index.html");
Expand Down