init
This commit is contained in:
25
Dockerfile
Normal file
25
Dockerfile
Normal file
@@ -0,0 +1,25 @@
|
||||
# 使用官方 Python 运行时作为基础镜像
|
||||
FROM python:3.9-slim
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制 requirements.txt 文件到工作目录
|
||||
COPY requirements.txt .
|
||||
|
||||
# 安装项目依赖
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 复制项目代码到工作目录
|
||||
COPY . .
|
||||
|
||||
# 创建非 root 用户
|
||||
RUN useradd --create-home --shell /bin/bash app && \
|
||||
chown -R app:app /app
|
||||
USER app
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 5000
|
||||
|
||||
# 使用 Flask 内置服务器运行应用(生产环境建议使用 Gunicorn)
|
||||
CMD ["python", "app.py"]
|
||||
Reference in New Issue
Block a user