# Deploy Python Lambda function with custom Dockerfile to install Latex

**URL:** <https://forum.serverless.com/t/deploy-python-lambda-function-with-custom-dockerfile-to-install-latex/5858>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [September 18, 2018, 6:05am UTC](https://forum.serverless.com/t/deploy-python-lambda-function-with-custom-dockerfile-to-install-latex/5858 "2018-09-18T06:05:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spoecker](https://avatars.discourse-cdn.com/v4/letter/s/edb3f5/32.png) [@Spoecker](https://forum.serverless.com/u/Spoecker)\
**Post date:** [September 18, 2018, 6:05am UTC](https://forum.serverless.com/t/deploy-python-lambda-function-with-custom-dockerfile-to-install-latex/5858/1 "2018-09-18T06:05:14Z")

</div>

Hello,

I have a Python Lambda function that should create a PDF report. I tried to add a custom Dockerfile to install Latex at Lambda similar to [https://github.com/samoconnor/lambdalatex](https://github.com/samoconnor/lambdalatex)

But the function cannot find the installed Latex files.  
(The copied file template.tex at the end of the Dockerfile is there)

**My serverless.yaml:**

```
plugins:
    - serverless-python-requirements

custom:
    pythonRequirements:
   dockerizePip: non-linux
   dockerFile: Dockerfile

```

**The Dockerfile:**  
FROM lambci/lambda:build-python3.6

```
# The TeXLive installer needs md5 and wget.
RUN yum -y install perl-Digest-MD5 && \
    yum -y install wget \
    yum -y install latexmk

RUN mkdir /var/src
WORKDIR /var/src

# Download TeXLive installer.
ADD http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz /var/src/
#COPY install-tl-unx.tar.gz /var/src/

# Minimal TeXLive configuration profile.
COPY texlive.profile /var/src/

# Intstall base TeXLive system.
RUN tar xf install*.tar.gz
RUN cd install-tl-* && \
    ./install-tl --profile ../texlive.profile

ENV PATH=/var/task/texlive/2017/bin/x86_64-linux/:$PATH

# Install extra packages.
RUN tlmgr install xcolor \
                  tcolorbox \
                  pgf \
                  environ \
                  trimspaces \
                  etoolbox \
                  booktabs \
                  lastpage \
                  pgfplots \
                  marginnote \
                  tabu \
                  varwidth \
                  makecell \
                  enumitem \
                  setspace \
                  xwatermark \
                  catoptions \
                  ltxkeys \
                  framed \
                  parskip \
                  endnotes \
                  footmisc \
                  zapfding \
                  symbol \
                  lm \
                  sectsty \
                  stringstrings \
                  koma-script \
                  multirow \
                  calculator \
                  adjustbox \
                  xkeyval \
                  collectbox \
                  siunitx \
                  l3kernel \
                  l3packages \
                  helvetic \
                  charter \
                  latexmk

# Install latexmk.
RUN tlmgr install latexmk

# Remove LuaTeX.
RUN tlmgr remove --force luatex

# Remove large unneeded files.
RUN rm -rf /var/task/texlive/2017/tlpkg/texlive.tlpdb* \
           /var/task/texlive/2017/texmf-dist/source/latex/koma-script/doc \
           /var/task/texlive/2017/texmf-dist/doc 

RUN mkdir -p /var/task/texlive/2017/tlpkg/TeXLive/Digest/ && \
    mkdir -p /var/task/texlive/2017/tlpkg/TeXLive/auto/Digest/MD5/ && \
    cp /usr/lib64/perl5/vendor_perl/Digest/MD5.pm \
       /var/task/texlive/2017/tlpkg/TeXLive/Digest/ && \
    cp /usr/lib64/perl5/vendor_perl/auto/Digest/MD5/MD5.so \
       /var/task/texlive/2017/tlpkg/TeXLive/auto/Digest/MD5

FROM lambci/lambda:build-python3.6

WORKDIR /var/task

ENV PATH=/var/task/texlive/2017/bin/x86_64-linux/:$PATH
ENV PERL5LIB=/var/task/texlive/2017/tlpkg/TeXLive/

COPY template.tex /var/task/

```

The Python requirements from the requirements.txt are working perfectly.

Here is the output of the deploy from the Docker part:

Serverless: Building custom docker image from Dockerfile…  
Serverless: Docker Image: sls-py-reqs-custom

Do you have any idea what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![fumpierrez](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/fumpierrez/32/5241_2.png) [@fumpierrez](https://forum.serverless.com/u/fumpierrez)\
**Post date:** [February 13, 2021, 7:55pm UTC](https://forum.serverless.com/t/deploy-python-lambda-function-with-custom-dockerfile-to-install-latex/5858/2 "2021-02-13T19:55:24Z")

</div>

Did you get this working? I think the Dockerfile is just used locally and not used at all on the live deployments but I might be wrong

Long story short: Is it possible to use our own lambda image to run python ? To ship custom software when pip is not enough for all your needs
