Update Dockerfile
Browse files- Dockerfile +20 -37
Dockerfile
CHANGED
|
@@ -1,58 +1,41 @@
|
|
| 1 |
-
FROM golang:1.21 AS builder
|
| 2 |
-
|
| 3 |
-
WORKDIR /app
|
| 4 |
-
|
| 5 |
-
# 下载并解压 Cloudreve 源代码 (根据需要调整版本)
|
| 6 |
-
RUN go install github.com/cloudreve/Cloudreve/v3@latest
|
| 7 |
-
|
| 8 |
-
# 设置 Cloudreve 环境变量
|
| 9 |
-
ENV CGO_ENABLED=0
|
| 10 |
-
ENV GOOS=linux
|
| 11 |
-
ENV GOARCH=amd64
|
| 12 |
-
|
| 13 |
-
# 构建 Cloudreve (如果在 final 阶段下载预构建的二进制文件,则可能不需要此步骤)
|
| 14 |
-
# RUN go build -o cloudreve main.go
|
| 15 |
-
|
| 16 |
FROM alpine:latest
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
WORKDIR /opt/cloudreve
|
| 19 |
|
| 20 |
ENV TZ=Asia/Shanghai
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
RUN apk update &&
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
RUN wget https://github.com/cloudreve/Cloudreve/releases/download/3.8.3/cloudreve_3.8.3_linux_amd64.tar.gz
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
|
| 31 |
-
# 创建数据目录
|
| 32 |
RUN mkdir -p /opt/cloudreve/data
|
| 33 |
-
RUN chmod -R 755 /opt/cloudreve
|
| 34 |
-
|
| 35 |
-
# 将用户 www-data 添加到已存在的组
|
| 36 |
-
RUN adduser -u 1000 -D -S -G www-data www-data
|
| 37 |
|
| 38 |
-
#
|
| 39 |
-
RUN chown -R
|
| 40 |
|
| 41 |
-
# 创建 Python 虚拟环境并安装 webdavclient3
|
| 42 |
ENV VIRTUAL_ENV=/opt/venv
|
| 43 |
RUN python3 -m venv $VIRTUAL_ENV
|
| 44 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 45 |
RUN pip install --no-cache-dir requests webdavclient3
|
|
|
|
| 46 |
|
| 47 |
-
# 复制同步脚本
|
| 48 |
COPY sync_data.sh /opt/cloudreve/
|
|
|
|
| 49 |
RUN chmod +x /opt/cloudreve/sync_data.sh
|
| 50 |
|
| 51 |
-
|
| 52 |
-
EXPOSE 5212
|
| 53 |
|
| 54 |
-
|
| 55 |
-
USER www-data
|
| 56 |
|
| 57 |
-
|
| 58 |
-
CMD ["/bin/sh", "-c", "/opt/cloudreve/sync_data.sh; sleep 10; ./cloudreve -c /opt/cloudreve/cloudreve.ini"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM alpine:latest
|
| 2 |
|
| 3 |
+
# 創建一個非 root 使用者
|
| 4 |
+
ARG USER_ID=1000
|
| 5 |
+
ARG GROUP_ID=1000
|
| 6 |
+
RUN addgroup -g $GROUP_ID appuser && \
|
| 7 |
+
adduser -u $USER_ID -G appuser -s /bin/sh -D appuser
|
| 8 |
+
|
| 9 |
WORKDIR /opt/cloudreve
|
| 10 |
|
| 11 |
ENV TZ=Asia/Shanghai
|
| 12 |
|
| 13 |
+
# 直接使用您提供的下載連結
|
| 14 |
+
RUN apk update && \
|
| 15 |
+
apk add --no-cache wget unzip python3 py3-pip bash tar gzip jq curl && \
|
| 16 |
+
rm -rf /var/cache/apk/*
|
|
|
|
| 17 |
|
| 18 |
+
RUN wget -O cloudreve.tar.gz "https://github.com/cloudreve/Cloudreve/releases/download/3.8.3/cloudreve_3.8.3_linux_amd64.tar.gz" && \
|
| 19 |
+
tar -zxvf cloudreve.tar.gz && \
|
| 20 |
+
rm cloudreve.tar.gz
|
| 21 |
|
|
|
|
| 22 |
RUN mkdir -p /opt/cloudreve/data
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
# 設定 /opt/cloudreve 的擁有者為非 root 使用者
|
| 25 |
+
RUN chown -R appuser:appuser /opt/cloudreve
|
| 26 |
|
|
|
|
| 27 |
ENV VIRTUAL_ENV=/opt/venv
|
| 28 |
RUN python3 -m venv $VIRTUAL_ENV
|
| 29 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
| 30 |
RUN pip install --no-cache-dir requests webdavclient3
|
| 31 |
+
RUN pip install --upgrade webdavclient3
|
| 32 |
|
|
|
|
| 33 |
COPY sync_data.sh /opt/cloudreve/
|
| 34 |
+
RUN chown appuser:appuser /opt/cloudreve/sync_data.sh
|
| 35 |
RUN chmod +x /opt/cloudreve/sync_data.sh
|
| 36 |
|
| 37 |
+
USER appuser
|
|
|
|
| 38 |
|
| 39 |
+
EXPOSE 5212
|
|
|
|
| 40 |
|
| 41 |
+
CMD ["/bin/sh", "-c", "/opt/cloudreve/cloudreve -c /opt/cloudreve/config.ini & /opt/cloudreve/sync_data.sh"]
|
|
|