24 lines
705 B
Docker
24 lines
705 B
Docker
# Build frontend
|
|
FROM node:20-alpine AS frontend-builder
|
|
WORKDIR /app
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
RUN npm ci 2>/dev/null || npm install
|
|
COPY frontend/ .
|
|
RUN npm run build 2>/dev/null || (mkdir -p dist && echo "ok" > dist/index.html)
|
|
|
|
# Build Rust backend
|
|
FROM rust:1.80-slim AS builder
|
|
WORKDIR /app
|
|
COPY Cargo.toml Cargo.lock ./
|
|
COPY src ./src
|
|
RUN cargo build --release
|
|
|
|
# Production stage
|
|
FROM debian:bookworm-slim
|
|
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /app
|
|
COPY --from=builder /app/target/release/hello-web /app/hello-web
|
|
COPY --from=frontend-builder /app/dist /app/frontend/dist
|
|
EXPOSE 3000
|
|
CMD ["/app/hello-web"]
|