24 lines
742 B
Docker
24 lines
742 B
Docker
# Stage 1: Build the Svelte frontend
|
|
FROM node:18 as frontend-builder
|
|
WORKDIR /app/frontend
|
|
COPY frontend/ .
|
|
RUN npm install
|
|
RUN npm run build
|
|
|
|
# Stage 2: Build the Rust backend (statically linked)
|
|
FROM rust:1.83 as backend-builder
|
|
WORKDIR /app/backend
|
|
COPY backend/ .
|
|
# Add the musl target for static linking
|
|
RUN rustup target add x86_64-unknown-linux-musl
|
|
# Build the binary with musl
|
|
RUN cargo build --release --target x86_64-unknown-linux-musl
|
|
|
|
# Final Stage
|
|
FROM debian:bullseye-slim
|
|
WORKDIR /app
|
|
COPY --from=frontend-builder /app/frontend/build ./frontend/build
|
|
# Copy the statically linked binary
|
|
COPY --from=backend-builder /app/backend/target/x86_64-unknown-linux-musl/release/formies_be ./formies_be
|
|
EXPOSE 8080
|
|
CMD ["./formies_be"] |