diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..f699e33ea --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM python:3.9.0-alpine + +RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip +RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple mkdocs-material==9.0.2 + +WORKDIR /app + +COPY codes /app/codes +COPY docs /app/docs +COPY mkdocs.yml /app/mkdocs.yml + +RUN mkdir ./docs/overrides && mkdocs build + +EXPOSE 8000 + +CMD ["mkdocs", "serve", "-a", "0.0.0.0:8000"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..6a472b173 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +version: '3' +services: + hello-algo: + build: . + ports: + - "8000:8000" + \ No newline at end of file diff --git a/docs/chapter_preface/contribution.md b/docs/chapter_preface/contribution.md index c710e6de5..4e5f3dc85 100644 --- a/docs/chapter_preface/contribution.md +++ b/docs/chapter_preface/contribution.md @@ -41,4 +41,26 @@ comments: true 非常欢迎您和我一同来创作本书! +## 离线部署 + +### Docker + +使用本教程前,请确保 Docker 已经安装并启动。 + +根据如下命令离线部署。 + +```bash +git clone https://github.com/krahets/hello-algo.git +cd hello-algo +docker-compose up -d +``` + +稍等片刻,即可通过浏览器打开 `http://localhost:8000` 访问本教程。 + +使用如下命令删除部署。 + +```bash +docker-compose down +``` + (TODO:教学视频)