-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebianbased-Dockerfile
45 lines (32 loc) · 1.36 KB
/
debianbased-Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Stage 1: Build Stage using debian:buster-slim for building the Rust project
FROM debian:buster-slim AS build
# Set environment variables to avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies: curl for downloading Rust, and build-essential for compiling Rust packages
RUN apt-get update && \
apt-get install -y curl build-essential && \
rm -rf /var/lib/apt/lists/*
# Install Rust using rustup (Rust installer)
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
# Set the path for Rust (cargo and rustc)
ENV PATH="/root/.cargo/bin:${PATH}"
# Install mdbook via cargo (Rust's package manager)
RUN cargo install mdbook
# Create an app directory for your project
WORKDIR /app
# Copy all the contents of your current project
COPY . .
# Build the book
RUN mdbook build
# Stage 2: Production Stage using debian:buster-slim for serving the book
FROM debian:buster-slim
# Install minimal runtime dependencies
RUN apt-get update && apt-get install -y ca-certificates bash && rm -rf /var/lib/apt/lists/*
# Copy the built book and mdbook binary from the build stage
COPY --from=build /root/.cargo/bin/mdbook /usr/local/bin/mdbook
COPY --from=build /app /app
# Expose the port that mdbook serve uses (default is 3000)
EXPOSE 3000
# Default command to serve the book, ensuring it binds to 0.0.0.0
WORKDIR /app
CMD ["mdbook", "serve", "-n", "0.0.0.0"]