feat: add Dockerfiles, nginx config, serve frontend from Rust backend
This commit is contained in:
+8
-18
@@ -1,26 +1,16 @@
|
||||
# Build frontend
|
||||
FROM node:20-alpine AS frontend-build
|
||||
WORKDIR /app
|
||||
COPY frontend/package.json frontend/package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY frontend/ .
|
||||
RUN npm run build
|
||||
|
||||
# Build Rust backend
|
||||
FROM rust:1.75 AS rust-builder
|
||||
# Build stage
|
||||
FROM rust:1.80-slim AS builder
|
||||
WORKDIR /app
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY src/ ./src/
|
||||
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
||||
RUN cargo build --release
|
||||
COPY src ./src
|
||||
RUN cargo build --release
|
||||
RUN cp target/release/hello-web /app/hello-web
|
||||
|
||||
# Final image
|
||||
# Production stage
|
||||
FROM debian:bookworm-slim
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /app
|
||||
COPY --from=rust-builder /app/hello-web /app/hello-web
|
||||
COPY --from=frontend-build /app/dist /app/frontend/dist
|
||||
COPY --from=builder /app/target/release/hello-web /app/hello-web
|
||||
EXPOSE 3000
|
||||
CMD ["/app/hello-web"]
|
||||
|
||||
Reference in New Issue
Block a user