Skip to content

Commit

Permalink
新增 web 页面
Browse files Browse the repository at this point in the history
  • Loading branch information
xjxjin committed Jan 6, 2025
1 parent 5a1967d commit 0c42312
Show file tree
Hide file tree
Showing 3 changed files with 499 additions and 545 deletions.
70 changes: 39 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,56 @@
# 使用 Python 精简版作为基础镜像
FROM python:3.10-slim AS builder
# 使用 Python Alpine 作为构建镜像
FROM python:3.10-alpine AS builder

# 设置工作目录
WORKDIR /app

# 安装构建依赖
RUN apk add --no-cache \
gcc \
musl-dev \
python3-dev \
libffi-dev \
openssl-dev

# 复制依赖文件
COPY requirements.txt .

# 安装构建依赖和项目依赖
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
python3-dev \
build-essential \
libssl-dev \
libffi-dev \
&& pip install --upgrade pip \
&& pip install --no-cache-dir wheel setuptools \
&& pip install --no-cache-dir -r requirements.txt \
&& apt-get purge -y --auto-remove \
gcc \
python3-dev \
build-essential \
libssl-dev \
libffi-dev \
&& rm -rf /var/lib/apt/lists/*

# 复制项目文件
COPY . .

# 使用精简版运行时镜像
FROM python:3.10-slim
# 安装依赖到指定目录
RUN pip install --no-cache-dir -r requirements.txt --target=/install

# 使用更小的运行时镜像
FROM python:3.10-alpine

# 设置工作目录
WORKDIR /app

# 复制已安装的依赖和项目文件
COPY --from=builder /usr/local/lib/python3.10/site-packages/ /usr/local/lib/python3.10/site-packages/
COPY --from=builder /app /app
# 复制安装的依赖
COPY --from=builder /install /usr/local/lib/python3.10/site-packages

# 只复制必要的项目文件
COPY alist-sync-web.py alist_sync.py ./
COPY static ./static
COPY templates ./templates

# 创建必要的目录
RUN mkdir -p /app/data/config /app/data/log && \
# 设置权限
chmod -R 755 /app/data && \
# 清理不必要的文件
find /usr/local/lib/python3.10/site-packages -name "*.pyc" -delete && \
find /usr/local/lib/python3.10/site-packages -name "__pycache__" -exec rm -r {} + && \
# 删除测试文件和文档
find /usr/local/lib/python3.10/site-packages -name "tests" -type d -exec rm -r {} + && \
find /usr/local/lib/python3.10/site-packages -name "*.txt" -delete && \
find /usr/local/lib/python3.10/site-packages -name "*.md" -delete

# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/app:$PATH"

# 暴露端口
EXPOSE 52441

# 修改启动命令,使用正确的文件名
# 设置启动命令
CMD ["python", "alist-sync-web.py"]
Loading

0 comments on commit 0c42312

Please sign in to comment.