Update Dockerfile
Browse files- Dockerfile +10 -11
Dockerfile
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
-
FROM
|
| 2 |
|
| 3 |
WORKDIR /opt/app
|
| 4 |
|
| 5 |
ENV TZ Asia/Shanghai
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# 安装必要的依赖
|
| 9 |
-
RUN
|
| 10 |
-
&& apk update && apk add --no-cache wget tar gzip python3 py3-pip curl bash tzdata ca-certificates
|
| 11 |
|
| 12 |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
| 13 |
|
|
@@ -18,8 +20,8 @@ COPY app1 /opt/app/
|
|
| 18 |
RUN mkdir -p /opt/app/app_data
|
| 19 |
RUN chmod -R 755 /opt/app
|
| 20 |
|
| 21 |
-
# 将用户 www-data 添加到已存在的组
|
| 22 |
-
RUN
|
| 23 |
|
| 24 |
# 更改 /opt/app 目录的所有权为 www-data 用户
|
| 25 |
RUN chown -R www-data:www-data /opt/app
|
|
@@ -28,10 +30,7 @@ RUN chown -R www-data:www-data /opt/app
|
|
| 28 |
ENV VIRTUAL_ENV=/opt/venv
|
| 29 |
RUN python3 -m venv $VIRTUAL_ENV
|
| 30 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 31 |
-
RUN
|
| 32 |
-
|
| 33 |
-
# 安装一些通用库,以解决潜在的依赖问题
|
| 34 |
-
RUN apk add --no-cache libstdc++ libgcc libcurl
|
| 35 |
|
| 36 |
# 复制同步脚本
|
| 37 |
COPY sync_data.sh /opt/app/
|
|
@@ -45,4 +44,4 @@ EXPOSE 5432
|
|
| 45 |
USER www-data
|
| 46 |
|
| 47 |
# 设置运行 app 的命令,包含同步脚本
|
| 48 |
-
CMD ["/bin/
|
|
|
|
| 1 |
+
FROM ubuntu:latest
|
| 2 |
|
| 3 |
WORKDIR /opt/app
|
| 4 |
|
| 5 |
ENV TZ Asia/Shanghai
|
| 6 |
+
|
| 7 |
+
# 设置 apt 镜像源为国内镜像,加快下载速度
|
| 8 |
+
RUN sed -i s@/archive.ubuntu.com/@/mirrors.ustc.edu.cn/@g /etc/apt/sources.list
|
| 9 |
+
RUN sed -i s@/security.ubuntu.com/@/mirrors.ustc.edu.cn/@g /etc/apt/sources.list
|
| 10 |
|
| 11 |
# 安装必要的依赖
|
| 12 |
+
RUN apt-get update && apt-get install -y wget tar gzip python3 python3-pip curl bash tzdata ca-certificates --no-install-recommends
|
|
|
|
| 13 |
|
| 14 |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
| 15 |
|
|
|
|
| 20 |
RUN mkdir -p /opt/app/app_data
|
| 21 |
RUN chmod -R 755 /opt/app
|
| 22 |
|
| 23 |
+
# 将用户 www-data 添加到已存在的组 (Ubuntu 中通常已有 www-data 用户,但为了保险起见可以尝试添加)
|
| 24 |
+
RUN useradd -u 1000 -ms /bin/bash www-data || true
|
| 25 |
|
| 26 |
# 更改 /opt/app 目录的所有权为 www-data 用户
|
| 27 |
RUN chown -R www-data:www-data /opt/app
|
|
|
|
| 30 |
ENV VIRTUAL_ENV=/opt/venv
|
| 31 |
RUN python3 -m venv $VIRTUAL_ENV
|
| 32 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 33 |
+
RUN pip3 install --no-cache-dir requests webdavclient3
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
# 复制同步脚本
|
| 36 |
COPY sync_data.sh /opt/app/
|
|
|
|
| 44 |
USER www-data
|
| 45 |
|
| 46 |
# 设置运行 app 的命令,包含同步脚本
|
| 47 |
+
CMD ["/bin/bash", "-c", "/opt/app/sync_data.sh; sleep 10; ./app1 -c /opt/app/app.ini"]
|