38 lines
1.6 KiB
Docker
38 lines
1.6 KiB
Docker
FROM python:3.11-slim
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Ensure LibreOffice program libraries are on PYTHONPATH and LD_LIBRARY_PATH
|
|
ENV PYTHONPATH=/usr/lib/libreoffice/program:$PYTHONPATH
|
|
ENV LD_LIBRARY_PATH=/usr/lib/libreoffice/program:$LD_LIBRARY_PATH
|
|
|
|
# 配置国内 apt 镜像源(加速包下载)
|
|
# 使用阿里云 Debian 镜像源(适用于 Debian/Ubuntu 系统)
|
|
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
|
|
sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || \
|
|
(echo "deb https://mirrors.aliyun.com/debian/ bookworm main" > /etc/apt/sources.list && \
|
|
echo "deb https://mirrors.aliyun.com/debian/ bookworm-updates main" >> /etc/apt/sources.list && \
|
|
echo "deb https://mirrors.aliyun.com/debian-security/ bookworm-security main" >> /etc/apt/sources.list)
|
|
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends \
|
|
libreoffice-core libreoffice-writer libreoffice-common \
|
|
libreoffice-base libreoffice-math libreoffice-impress \
|
|
ca-certificates curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
COPY requirements.txt /app/requirements.txt
|
|
RUN pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
|
|
|
|
COPY docker/soffice/app.py /app/app.py
|
|
COPY docker/soffice/README.md /app/README.md
|
|
|
|
EXPOSE 8003
|
|
|
|
# Start uvicorn with python3 to ensure sys.executable points to python3
|
|
# Use port 8003 to match the compose mapping and .env example
|
|
CMD ["python3", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8003"]
|