docker映象構建libreoffice轉換檔案

mappleyan發表於2024-09-10

具體需求:

根據Libreoffice最新版本,建立一個容器環境,用於檔案不同型別的轉換

# 使用阿里雲的Python映象
FROM dockerpull.com/python:3.9-slim

# 設定工作目錄
WORKDIR /app

# 更新debian系統的APT源列表為阿里
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get clean && \
    echo 'deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib' > /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib' >> /etc/apt/sources.list && \
    echo 'deb https://mirrors.aliyun.com/debian-security/ bookworm-security main' >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main' >> /etc/apt/sources.list && \
    echo 'deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib' >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib' >> /etc/apt/sources.list && \
    echo 'deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib' >> /etc/apt/sources.list && \
    echo 'deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib' >> /etc/apt/sources.list && \
    apt-get update

# 安裝基礎編譯環境等依賴
RUN apt-get install -y --no-install-recommends build-essential libeigen3-dev gcc libmariadb-dev && \
    rm -rf /var/lib/apt/lists/*

# 安裝LibreOffice(使用阿里雲的APT源)
RUN apt-get update && \
apt-get install -y --no-install-recommends libreoffice && \
rm -rf /var/lib/apt/lists/*

# 複製應用程式碼, 當前dockerfile所在路徑下的所有檔案到當前的工作目錄中
COPY . .

# 安裝Python依賴 根據當前路徑下的requirements.txt
RUN pip install --no-cache-dir -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/

# 暴露埠
EXPOSE 5000

# 執行主程式
CMD ["sh", "start.sh"]

docker-compose

version: '3'

services:
  ppt2pdf_service:
    image: ppt2pdf:latest
    container_name: ppt2pdf
    restart: always
    # environment:
    #   - ENV_VAR_NAME=value
    # volumes:
    #   - ./host/path:/container/path
    ports:
      - "3690:5000"
    networks:
      - ppt2pdf_network

networks:
  ppt2pdf_network:
    driver: bridge

相關文章