formies/Dockerfile

24 lines
742 B
Docker
Raw Permalink Normal View History

2025-01-03 10:26:04 +01:00
# Stage 1: Build the Svelte frontend
2024-12-27 14:05:56 +01:00
FROM node:18 as frontend-builder
2025-01-03 10:26:04 +01:00
WORKDIR /app/frontend
COPY frontend/ .
2024-12-27 14:05:56 +01:00
RUN npm install
RUN npm run build
2025-01-03 13:52:48 +01:00
# Stage 2: Build the Rust backend (statically linked)
2025-01-03 10:45:33 +01:00
FROM rust:1.83 as backend-builder
2025-01-03 10:26:04 +01:00
WORKDIR /app/backend
COPY backend/ .
2025-01-03 13:52:48 +01:00
# 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
2024-12-27 14:05:56 +01:00
2025-01-03 13:45:35 +01:00
# Final Stage
2024-12-27 14:05:56 +01:00
FROM debian:bullseye-slim
WORKDIR /app
2025-01-03 13:45:35 +01:00
COPY --from=frontend-builder /app/frontend/build ./frontend/build
2025-01-03 13:52:48 +01:00
# Copy the statically linked binary
COPY --from=backend-builder /app/backend/target/x86_64-unknown-linux-musl/release/formies_be ./formies_be
2024-12-27 14:05:56 +01:00
EXPOSE 8080
2025-01-03 13:45:35 +01:00
CMD ["./formies_be"]