ed / Dockerfile
BG5's picture
Update Dockerfile
00d812c verified
# 使用 Ubuntu 22.04 作为基础镜像
FROM ich777/microsoft-edge
# 设置环境变量以避免交互式提示
ENV DEBIAN_FRONTEND=noninteractive
# 更新包列表并安装必要的依赖
RUN apt-get update && apt-get install -y \
wget \
gnupg2 \
software-properties-common \
&& apt-get update \
&& apt-get install -y python3.11 python3.11-venv \
&& apt-get install -y python3-pip \
&& apt-get clean
# 创建 python 的符号链接
RUN ln -s /usr/bin/python3.11 /usr/bin/python
# # 创建非特权用户
RUN useradd -m -s /bin/bash appuser
# 设置工作目录
WORKDIR /opt/scripts
# 将当前目录内容复制到容器的 /app 中
COPY . /opt/scripts
RUN chmod +x /opt/scripts/start.sh
# 更改目录和文件的所有者
RUN chown -R appuser:appuser /opt/scripts
# 打印 /opt/scripts/start.sh 文件的内容
RUN cat /opt/scripts/start.sh
# 删除 /opt/scripts/start.sh 文件
# RUN rm /opt/scripts/start.sh
# 安装任何需要的包,使用 --ignore-installed 选项
RUN pip install --ignore-installed --break-system-packages -r requirements.txt
# 确保 /opt/scripts/start.sh 脚本具有执行权限
RUN mkdir -p /opt/scripts && chmod +x /opt/scripts/start.sh
# 以 root 用户运行
USER root
# 确保 /var/lib/apt/lists/partial 目录存在并具有正确的权限
RUN mkdir -p /var/lib/apt/lists/partial && chmod 755 /var/lib/apt/lists/partial
# 切换到非特权用户
USER appuser
# 设置默认命令(可根据需要修改)
CMD ["python3.11", "main.py && /opt/scripts/start.sh"]