chore: Switch to mold linker and fix Dockerfile build
Use mold linker in .cargo/config.toml instead of lld. Add binutils and mkdir -p to Dockerfile builder stage. Update fly.toml model.
This commit is contained in:
parent
197f0f541b
commit
b1e0a41797
3 changed files with 46 additions and 30 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
[target.x86_64-unknown-linux-gnu]
|
[target.x86_64-unknown-linux-gnu]
|
||||||
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
|
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||||
|
|
||||||
[target.aarch64-unknown-linux-gnu]
|
[target.aarch64-unknown-linux-gnu]
|
||||||
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
|
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||||
|
|
|
||||||
70
Dockerfile
70
Dockerfile
|
|
@ -1,43 +1,59 @@
|
||||||
# ── Builder stage ────────────────────────────────────────────────────────
|
# syntax=docker/dockerfile:1
|
||||||
FROM rust:1.93-slim-bookworm AS builder
|
|
||||||
|
|
||||||
|
# Multi-stage Dockerfile for brewlog.
|
||||||
|
# Uses chisel to create a minimal Ubuntu rootfs for the runtime image.
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Builder — Ubuntu with Rust toolchain pre-installed
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
FROM ubuntu/rust:1.93-26.04_edge AS builder
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
clang \
|
|
||||||
lld \
|
|
||||||
libssl-dev \
|
|
||||||
pkg-config \
|
pkg-config \
|
||||||
|
libssl-dev \
|
||||||
|
mold \
|
||||||
|
binutils \
|
||||||
|
curl \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install tailwindcss standalone
|
# Install tailwindcss standalone (needed by build.rs)
|
||||||
RUN curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
|
RUN mkdir -p /usr/local/bin \
|
||||||
|
&& curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 \
|
||||||
-o /usr/local/bin/tailwindcss && chmod +x /usr/local/bin/tailwindcss
|
-o /usr/local/bin/tailwindcss && chmod +x /usr/local/bin/tailwindcss
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy dependency files first for layer caching
|
|
||||||
COPY Cargo.toml Cargo.lock ./
|
|
||||||
|
|
||||||
# Create a dummy main.rs to build dependencies
|
|
||||||
RUN mkdir src && echo "fn main() {}" > src/main.rs && \
|
|
||||||
cargo build --release && \
|
|
||||||
rm -rf src
|
|
||||||
|
|
||||||
# Copy full source and build
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN cargo build --release --locked
|
|
||||||
|
|
||||||
# ── Runtime stage ────────────────────────────────────────────────────────
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||||
FROM debian:bookworm-slim
|
--mount=type=cache,target=/app/target \
|
||||||
|
cargo build --release --locked \
|
||||||
|
&& mkdir -p /out \
|
||||||
|
&& cp target/release/brewlog /out/brewlog
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Chisel — minimal Ubuntu rootfs
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
FROM ubuntu:26.04 AS chisel
|
||||||
|
ARG TARGETARCH=amd64
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates \
|
curl ca-certificates \
|
||||||
libssl3 \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN curl -sL "https://github.com/canonical/chisel/releases/download/v1.4.1/chisel_v1.4.1_linux_${TARGETARCH}.tar.gz" \
|
||||||
|
| tar xz -C /usr/local/bin
|
||||||
|
|
||||||
RUN groupadd -g 1000 brewlog && useradd -u 1000 -g brewlog -m brewlog
|
RUN mkdir /rootfs && chisel cut --root /rootfs \
|
||||||
|
base-files_base \
|
||||||
COPY --from=builder /app/target/release/brewlog /usr/local/bin/brewlog
|
base-files_release-info \
|
||||||
|
ca-certificates_data \
|
||||||
USER 1000:1000
|
libgcc-s1_libs \
|
||||||
|
libc6_libs \
|
||||||
|
libssl3t64_libs \
|
||||||
|
openssl_bins
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Runtime — scratch with chisel rootfs
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=chisel /rootfs /
|
||||||
|
COPY --from=builder /out/brewlog /usr/local/bin/brewlog
|
||||||
|
USER 65534:65534
|
||||||
ENTRYPOINT ["brewlog", "serve", "--database-url", "sqlite:///data/brewlog.db"]
|
ENTRYPOINT ["brewlog", "serve", "--database-url", "sqlite:///data/brewlog.db"]
|
||||||
|
|
|
||||||
2
fly.toml
2
fly.toml
|
|
@ -6,7 +6,7 @@ primary_region = 'lhr'
|
||||||
[build]
|
[build]
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
BREWLOG_OPENROUTER_MODEL = 'google/gemini-3-flash-preview'
|
BREWLOG_OPENROUTER_MODEL = 'google/gemini-3.5-flash'
|
||||||
BREWLOG_RP_ID = 'coffee.jnsgr.uk'
|
BREWLOG_RP_ID = 'coffee.jnsgr.uk'
|
||||||
BREWLOG_BIND_ADDRESS = '0.0.0.0:3000'
|
BREWLOG_BIND_ADDRESS = '0.0.0.0:3000'
|
||||||
BREWLOG_RP_ORIGIN = 'https://coffee.jnsgr.uk'
|
BREWLOG_RP_ORIGIN = 'https://coffee.jnsgr.uk'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue