Deploy Python Lambda function with custom Dockerfile to install Latex


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

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:

    - serverless-python-requirements

   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 /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 \

# 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 \

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/ \
       /var/task/texlive/2017/tlpkg/TeXLive/Digest/ && \
    cp /usr/lib64/perl5/vendor_perl/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?

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