Create Dockerfile
Browse files- Dockerfile +33 -0
Dockerfile
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 使用较小的基础镜像
|
2 |
+
FROM python:3.9-slim
|
3 |
+
|
4 |
+
# 设置环境变量
|
5 |
+
ENV TZ=Asia/Shanghai
|
6 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
7 |
+
|
8 |
+
# 安装依赖并设置时区
|
9 |
+
RUN apt-get update && \
|
10 |
+
apt-get install --no-install-recommends -y tzdata git && \
|
11 |
+
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
|
12 |
+
echo "${TZ}" > /etc/timezone && \
|
13 |
+
apt-get clean && rm -rf /var/lib/apt/lists/*
|
14 |
+
|
15 |
+
# 配置 Git 用户信息
|
16 |
+
RUN git config --global http.postBuffer 524288000
|
17 |
+
RUN git config --global user.name "fb"
|
18 |
+
RUN git config --global user.email "fb@@users.noreply.github.com"
|
19 |
+
|
20 |
+
# 创建非 root 用户并切换用户环境
|
21 |
+
RUN useradd -m user
|
22 |
+
USER user
|
23 |
+
|
24 |
+
# 克隆仓库
|
25 |
+
RUN git clone https://github.com/kuanghongjie/FileCodeBox /home/user/app
|
26 |
+
|
27 |
+
# 设置工作目录并安装 Python 依赖
|
28 |
+
WORKDIR /home/user/app
|
29 |
+
RUN pip install --no-cache-dir --user -r requirements.txt
|
30 |
+
|
31 |
+
# 暴露端口并运行应用
|
32 |
+
EXPOSE 12345
|
33 |
+
CMD ["python", "main.py"]
|