From 6ca2d1a5f25cba3c1f25f268a1c38d9a774e51d8 Mon Sep 17 00:00:00 2001 From: qianlitt Date: Thu, 29 May 2025 21:15:03 +0800 Subject: [PATCH 1/2] feat: local deployment with Docker --- Dockerfile | 11 +++++++++++ compose.yaml | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 Dockerfile create mode 100644 compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1697fa33 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM rust:1.87-slim-bookworm AS builder + +ENV CARGO_HOME=/usr/local/cargo +RUN cargo install mdbook + +WORKDIR /app +COPY . . +RUN mdbook build --dest-dir /book + +FROM nginx:alpine +COPY --from=builder /book /usr/share/nginx/html diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..79dfbf0a --- /dev/null +++ b/compose.yaml @@ -0,0 +1,7 @@ +services: + web: + image: rust-course:latest + container_name: rust-course + ports: + - 3001:80 + restart: unless-stopped From d1142d7c757df78c122b785f803ee56d62a5dd86 Mon Sep 17 00:00:00 2001 From: qianlitt Date: Thu, 29 May 2025 21:26:59 +0800 Subject: [PATCH 2/2] docs: add docker deployment docs --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 490b6f14..96663107 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,17 @@ 总之在写作过程中我们始终铭记初心:为中国用户打造一门**全面的、深入的、持续更新的** Rust 教程。 新手用来入门,老手用来提高,高手用来提升生产力。 +### docker + +使用 docker 部署本教程: + +```sh +docker build -t rust-course . +docker-compose up -d +``` + +随后即可通过浏览器在 http://localhost:3001 中阅读。 + ## 🏆 贡献者 非常感谢本教程的[所有贡献者](https://github.com/sunface/rust-course/graphs/contributors),正是有了你们,才有了现在的高质量 Rust 教程!