diff --git a/Dockerfile b/Dockerfile index d1cfb8f0..1a6501b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ #### SERVER ############################################################################################ -# Using the `rust-musl-builder` as base image, instead of -# the official Rust toolchain FROM clux/muslrust:stable AS chef USER root RUN cargo install cargo-chef @@ -13,13 +11,17 @@ FROM chef AS planner COPY ./pentaract . RUN cargo chef prepare --recipe-path recipe.json -FROM chef AS builder +FROM chef AS builder COPY --from=planner /app/recipe.json recipe.json -# Build dependencies - this is the caching Docker layer! -RUN cargo chef cook --release --target x86_64-unknown-linux-musl --recipe-path recipe.json -# Build application + +# Build deps (cache) +RUN cargo chef cook --release --target aarch64-unknown-linux-musl --recipe-path recipe.json + +# Build app COPY ./pentaract . -RUN cargo build --target x86_64-unknown-linux-musl --release +RUN cargo build --release --target aarch64-unknown-linux-musl + +RUN cp /app/target/aarch64-unknown-linux-musl/release/pentaract /app/pentaract ############################################################################################ #### UI @@ -28,18 +30,23 @@ RUN cargo build --target x86_64-unknown-linux-musl --release FROM node:21-slim AS ui WORKDIR /app COPY ./ui . + RUN npm install -g pnpm RUN pnpm i -ENV VITE_API_BASE /api + +ENV VITE_API_BASE=/api RUN pnpm run build ############################################################################################ #### RUNNING ############################################################################################ -# We do not need the Rust toolchain to run the binary! FROM scratch AS runtime -COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/pentaract / + COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +COPY --from=builder /app/pentaract /pentaract + COPY --from=ui /app/dist /ui + ENTRYPOINT ["/pentaract"] diff --git a/docker-compose.yml b/docker-compose.yml index abcf614e..a3fd9a08 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: env_file: - .env ports: - - ${PORT}:8000 + - ${PORT}:${PORT} restart: unless-stopped depends_on: - db