Skip to content

Commit 424468a

Browse files
Merge pull request wuhan2020#29 from rexwangcc/master
容器化api-server
2 parents d7149f8 + 739246f commit 424468a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Align with the CI/CD YML
2+
FROM python:2.7
3+
4+
# Setup workdir
5+
WORKDIR /api-server
6+
7+
# Copy src files
8+
COPY . .
9+
10+
# Install deps
11+
RUN pip install -r requirements.txt
12+
13+
# Temporary hack until PR https://github.com/wuhan2020/api-server/pull/27 is merged
14+
RUN mkdir -p /home/wuhan2020/wuhan2020
15+
16+
# Expose port 5000
17+
EXPOSE 5000
18+
19+
# Start the server
20+
ENTRYPOINT [ "bash", "bootstrap"]

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,26 @@ git clone https://github.com/wuhan2020/wuhan2020
99
pip install -r requirements.txt
1010
bash bootstrap
1111
```
12-
然后就可以在`http://[your-ip]:9000/wuhan2020/[list_path]`调试api
12+
13+
然后就可以在`http://your-ip:9000/wuhan2020/`调试api
1314
注意`list_path`是在`utils.py`中被`data.route`注册的path,
1415
`your-ip`默认是127.0.0.1
16+
17+
## Docker 容器运行
18+
需要安装[Docker客户端](https://www.docker.com/products/docker-desktop).
19+
20+
### Build Docker Image
21+
在本项目根目录下执行 `docker build -t api-server:default .`.
22+
注意国内这一步可能会耗时较长.
23+
24+
### Run Docker Image
25+
执行 `docker run --name api-server --publish 5000:5000 api-server:default ` 后可在本地浏览器中打开http://localhost:5000/wuhan2020/{endpoint}. (使用 `-d` 进入detach模式)
26+
27+
_如果出现 `The container name "/api-server" is already in use` 报错可先执行 `docker rm api-server` 删除残留的同名容器._
28+
29+
### Stop Docker Container
30+
执行 `docker stop api-server `停止运行中的容器.
31+
1532
## 项目文件说明
1633

1734
```

0 commit comments

Comments
 (0)