FROM alpine:latest # 創建一個非 root 使用者 ARG USER_ID=1000 ARG GROUP_ID=1000 RUN addgroup -g $GROUP_ID appuser && \ adduser -u $USER_ID -G appuser -s /bin/sh -D appuser WORKDIR /opt/cloudreve ENV TZ=Asia/Shanghai # 直接使用您提供的下載連結 RUN apk update && \ apk add --no-cache wget unzip python3 py3-pip bash tar gzip jq curl && \ rm -rf /var/cache/apk/* RUN wget -O cloudreve.tar.gz "https://github.com/cloudreve/Cloudreve/releases/download/3.8.3/cloudreve_3.8.3_linux_amd64.tar.gz" && \ tar -zxvf cloudreve.tar.gz && \ rm cloudreve.tar.gz RUN mkdir -p /opt/cloudreve/data # 設定 /opt/cloudreve 的擁有者為非 root 使用者 RUN chown -R appuser:appuser /opt/cloudreve ENV VIRTUAL_ENV=/opt/venv RUN python3 -m venv $VIRTUAL_ENV ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN pip install --no-cache-dir requests webdavclient3 RUN pip install --upgrade webdavclient3 COPY sync_data.sh /opt/cloudreve/ RUN chown appuser:appuser /opt/cloudreve/sync_data.sh RUN chmod +x /opt/cloudreve/sync_data.sh USER appuser EXPOSE 5212 CMD ["/bin/sh", "-c", "/opt/cloudreve/cloudreve -c /opt/cloudreve/config.ini & /opt/cloudreve/sync_data.sh"]