Skip to content

Commit 0c5c15b

Browse files
committed
Docker
1 parent 2c62808 commit 0c5c15b

3 files changed

Lines changed: 100 additions & 0 deletions

File tree

.dockerignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 排除Windows特定文件
2+
*.dll
3+
*.exe
4+
# 排除Python缓存
5+
__pycache__/
6+
*.pyc
7+
*.pyo
8+
*.pyd
9+
# 排除IDE和编辑器文件
10+
.vscode/
11+
.idea/
12+
*.swp
13+
*.swo
14+
*~
15+
# 排除版本控制文件
16+
.git/
17+
.gitignore
18+
# 排除临时文件
19+
*.tmp
20+
*.temp
21+
# 排除日志文件
22+
*.log
23+
# 排除环境配置
24+
.env
25+
.env.local
26+
.env.*.local
27+
# 排除虚拟环境
28+
venv/
29+
env/
30+
.venv/
31+
# 排除文档
32+
README.md
33+
34+
mtr_pathfinder_temp/
35+
generated_images/
36+
# 排除测试文件
37+
*test*.py
38+
# 排除数据文件
39+
*.json

.github/workflows/build-docker.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
17+
- name: Login to Docker Hub
18+
uses: docker/login-action@v3
19+
with:
20+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
21+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
22+
23+
- name: Build and push Docker image
24+
id: build-and-push
25+
uses: docker/build-push-action@v5
26+
with:
27+
context: .
28+
push: true
29+
tags: |
30+
${{ secrets.DOCKER_HUB_USERNAME }}/mtr-pathfinder-webui:${{ github.event.release.tag_name }}
31+
${{ secrets.DOCKER_HUB_USERNAME }}/mtr-pathfinder-webui:latest
32+
33+
- name: Image digest
34+
run: echo ${{ steps.build-and-push.outputs.digest }}

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM python:slim-bookworm
2+
3+
# 设置工作目录
4+
WORKDIR /app
5+
6+
# 安装系统依赖,包括libraqm和其他可能需要的包
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
libraqm-dev \
9+
libfribidi-dev \
10+
libharfbuzz-dev \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
# 复制项目文件到容器中
14+
COPY . /app
15+
16+
# 安装Python依赖
17+
RUN pip install --no-cache-dir -r requirements.txt
18+
19+
# 暴露应用端口
20+
EXPOSE 5000
21+
22+
# 设置环境变量
23+
ENV FLASK_APP=main.py
24+
ENV FLASK_RUN_HOST=0.0.0.0
25+
26+
# 启动应用
27+
CMD ["flask", "run"]

0 commit comments

Comments
 (0)