feat(docker): update Dockerfile build process
This commit is contained in:
parent
3ba0dd1c14
commit
643533e843
|
|
@ -3,3 +3,4 @@ client/node_modules/
|
||||||
node_modules/
|
node_modules/
|
||||||
.env
|
.env
|
||||||
assets/
|
assets/
|
||||||
|
frontend/dist/
|
||||||
|
|
|
||||||
24
Dockerfile
24
Dockerfile
|
|
@ -1,5 +1,14 @@
|
||||||
# Build stage
|
# --- Frontend build stage ---
|
||||||
FROM rust:1.83-bookworm as builder
|
FROM node:20-bookworm as frontend-builder
|
||||||
|
|
||||||
|
WORKDIR /frontend
|
||||||
|
COPY frontend/package*.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY frontend ./
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# --- Backend build stage ---
|
||||||
|
FROM rust:1.83-bookworm as backend-builder
|
||||||
|
|
||||||
# Install system dependencies for OCR
|
# Install system dependencies for OCR
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
|
|
@ -15,10 +24,9 @@ RUN apt-get update && apt-get install -y \
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY Cargo.toml ./
|
COPY Cargo.toml ./
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
|
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
# Runtime stage
|
# --- Runtime stage ---
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
|
|
||||||
# Install runtime dependencies
|
# Install runtime dependencies
|
||||||
|
|
@ -30,14 +38,14 @@ RUN apt-get update && apt-get install -y \
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy the binary
|
# Copy backend binary
|
||||||
COPY --from=builder /app/target/release/readur /app/readur
|
COPY --from=backend-builder /app/target/release/readur /app/readur
|
||||||
|
|
||||||
# Create necessary directories
|
# Create necessary directories
|
||||||
RUN mkdir -p /app/uploads /app/watch /app/frontend
|
RUN mkdir -p /app/uploads /app/watch /app/frontend
|
||||||
|
|
||||||
# Copy frontend files (will be built separately)
|
# Copy built frontend from frontend-builder
|
||||||
COPY frontend/dist /app/frontend
|
COPY --from=frontend-builder /frontend/dist /app/frontend
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue