Files
make-space/Dockerfile
T

44 lines
1.5 KiB
Docker

FROM rust:1.99.1-trixie AS rust-build
WORKDIR /src
# Install wasm32 target and pinned wasm-bindgen-cli matching Cargo.lock (0.2.130)
RUN rustup target add wasm32-unknown-unknown \
&& cargo install wasm-bindgen-cli --version 0.2.130 --locked
COPY Cargo.toml Cargo.lock ./
COPY app ./app
COPY frontend ./frontend
COPY server ./server
COPY crates ./crates
COPY style ./style
COPY public ./public
# 1. Build Axum SSR server binary
RUN cargo build --release --locked --bin server
# 2. Build Leptos WASM hydrate bundle and assemble /src/target/site
RUN cargo build --profile wasm-release --locked --target wasm32-unknown-unknown -p frontend \
&& mkdir -p /src/target/site/pkg \
&& wasm-bindgen /src/target/wasm32-unknown-unknown/wasm-release/frontend.wasm \
--out-dir /src/target/site/pkg \
--out-name make-space \
--target web \
&& cp /src/target/site/pkg/make-space_bg.wasm /src/target/site/pkg/make-space.wasm \
&& cp /src/style/main.css /src/target/site/pkg/make-space.css \
&& cp -r /src/public/. /src/target/site/
FROM gcr.io/distroless/cc-debian13:nonroot AS runtime
ENV APP_ENV=production \
HOST=0.0.0.0 \
PORT=3000 \
LEPTOS_OUTPUT_NAME=make-space \
LEPTOS_SITE_ADDR=0.0.0.0:3000 \
LEPTOS_SITE_ROOT=/app/site \
LEPTOS_SITE_PKG_DIR=pkg
WORKDIR /app
COPY --from=rust-build --chown=65532:65532 /src/target/release/server /app/make-space
COPY --from=rust-build --chown=65532:65532 /src/target/site /app/site
USER 65532:65532
EXPOSE 3000
ENTRYPOINT ["/app/make-space"]