Skip to content

Commit feb41bc

Browse files
committed
feat: 添加 Dockerfile 和 .dockerignore 文件,配置 Python 环境和忽略规则
1 parent b8ce57b commit feb41bc

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

.dockerignore

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Python
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
*.so
11+
.Python
12+
.venv
13+
env/
14+
venv/
15+
ENV/
16+
env.bak/
17+
venv.bak/
18+
*.egg-info/
19+
.installed.cfg
20+
*.egg
21+
22+
# 配置和敏感文件
23+
.env
24+
config.yaml
25+
*.pem
26+
*.key
27+
28+
# 编辑器配置
29+
.idea/
30+
.vscode/
31+
*.swp
32+
*.swo
33+
34+
# 日志和临时文件
35+
logs/
36+
*.log
37+
tmp/
38+
.DS_Store
39+
40+
# 测试
41+
test/
42+
tests/
43+
.pytest_cache/
44+
.coverage
45+
htmlcov/
46+
47+
# 文档
48+
docs/
49+
*.md
50+
LICENSE
51+
52+
# 容器相关
53+
Dockerfile
54+
.dockerignore
55+
docker-compose.yml

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.12.9-alpine3.21
2+
3+
WORKDIR /app
4+
5+
ENV PYTHONDONTWRITEBYTECODE=1 \
6+
PYTHONUNBUFFERED=1
7+
8+
COPY requirements.txt .
9+
RUN pip install --no-cache-dir -r requirements.txt
10+
11+
RUN mkdir -p /app/templates \
12+
&& adduser --disabled-password --gecos "" appuser \
13+
&& chown -R appuser:appuser /app
14+
15+
COPY --chown=appuser:appuser . .
16+
17+
USER appuser
18+
19+
EXPOSE 8000
20+
21+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)