Skip to content
Open
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
27 changes: 17 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
env_file:
- .env
ports:
- ${PORT}:8000
- ${PORT}:${PORT}
restart: unless-stopped
depends_on:
- db
Expand Down