【问题标题】:Libreoffice convert-to not working in AWS docker imageLibreoffice 转换为在 AWS docker 映像中不起作用
【发布时间】:2022-02-02 06:12:15
【问题描述】:

我尝试使用 libreoffice 将文件转换为 pdf,目前我取得的最好成绩是:

RUN wget http://download.documentfoundation.org/libreoffice/stable/7.2.5/rpm/x86_64/LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN tar -xvzf LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN cd LibreOffice_7.2.5.2_Linux_x86-64_rpm/RPMS; yum -y localinstall *.rpm;
RUN yum -y install cairo
RUN echo instalacion completada
RUN /opt/libreoffice7.2/program/soffice.bin --version

直到这里,工作!显示正确安装的 libreoffice 版本,但尝试运行时,它不起作用:

RUN /opt/libreoffice7.2/program/soffice.bin --headless --convert-to pdf my_file.xlsm

返回:

命令'/bin/sh -c /opt/libreoffice7.2/program/soffice.bin --headless --convert-to pdf my_file.xlsm' 返回非零代码:81

我的完整 Dockerfile

# Pull the base image with python 3.8 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.8

RUN mkdir experimento/
COPY my_file.xlsm .

# Install OS packages for Pillow-SIMD
RUN yum -y install wget tar gzip zlib freetype-devel \
    gcc \
    ghostscript \
    lcms2-devel \
    libffi-devel \
    libimagequant-devel \
    libjpeg-devel \
    libraqm-devel \
    libtiff-devel \
    libwebp-devel \
    make \
    openjpeg2-devel \
    rh-python36 \
    rh-python36-python-virtualenv \
    sudo \
    tcl-devel \
    tk-devel \
    tkinter \
    which \
    xorg-x11-server-Xvfb \
    zlib-devel \
    && yum clean all

RUN wget http://download.documentfoundation.org/libreoffice/stable/7.2.5/rpm/x86_64/LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN tar -xvzf LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN cd LibreOffice_7.2.5.2_Linux_x86-64_rpm/RPMS; yum -y localinstall *.rpm;
RUN yum -y install cairo
RUN echo instalacion completada
RUN /opt/libreoffice7.2/program/soffice.bin --version
RUN /opt/libreoffice7.2/program/soffice.bin -h
RUN sudo find / -name soffice.bin
RUN yum install -y libXinerama.x86_64 cups-libs dbus-glib
RUN sudo /opt/libreoffice7.2/program/soffice.bin --headless --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --norestore --convert-to 'pdf:writer_pdf_Export' --outdir experimento/ my_file.xlsm

【问题讨论】:

  • 你能发布你完整的 Dockerfile 吗?你的基础图片是什么?
  • @Korgen 更新,我基于 public.ecr.aws/lambda/python:3.8
  • @Korgen 我找到了解决方案。你对它有什么看法?
  • LGTM。但是我建议查看 Docker 的 ENTRYPOINT、CMD 和 Dockerfile 最佳实践(例如 docs.docker.com/develop/develop-images/…
  • @Korgen 谢谢!我将应用最佳实践。非常感谢!

标签: amazon-web-services docker centos libreoffice


【解决方案1】:

我找到了解决办法,问题是soffice末尾的.bin

# Pull the base image with python 3.8 as a runtime for your Lambda
FROM public.ecr.aws/lambda/python:3.8

COPY my_file.xlsm .

# Install OS packages for Pillow-SIMD
RUN yum -y install curl wget tar gzip zlib freetype-devel \
    libxslt \
    libxslt1-dev \
    gcc \
    ghostscript \
    lcms2-devel \
    libffi-devel \
    libimagequant-devel \
    libjpeg-devel \
    libraqm-devel \
    libtiff-devel \
    libwebp-devel \
    make \
    openjpeg2-devel \
    rh-python36 \
    rh-python36-python-virtualenv \
    sudo \
    tcl-devel \
    tk-devel \
    tkinter \
    which \
    xorg-x11-server-Xvfb \
    zlib-devel \
    java \
    && yum clean all

RUN wget http://download.documentfoundation.org/libreoffice/stable/7.2.5/rpm/x86_64/LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz 
RUN tar -xvzf LibreOffice_7.2.5_Linux_x86-64_rpm.tar.gz
RUN cd LibreOffice_7.2.5.2_Linux_x86-64_rpm/RPMS; yum -y localinstall *.rpm;
RUN yum -y install cairo
RUN /opt/libreoffice7.2/program/soffice.bin --version
COPY carta_2020.xlsm /tmp/
RUN ls /tmp/
RUN /opt/libreoffice7.2/program/soffice --headless --convert-to pdf --outdir /tmp my_file.xlsm

【讨论】:

    猜你喜欢
    • 2016-03-18
    • 2014-03-30
    • 2017-06-27
    • 2021-10-09
    • 1970-01-01
    • 2018-06-06
    • 2020-06-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多