diff --git a/Dockerfile b/Dockerfile index 94b026e..a3378f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,6 +62,9 @@ RUN tlmgr install xcolor \ helvetic \ charter +# Install latexmk. +RUN tlmgr install latexmk + # Remove LuaTeX. RUN tlmgr remove --force luatex @@ -70,12 +73,19 @@ 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 --from=0 /var/task/ /var/task/ COPY lambda_function.py /var/task diff --git a/lambda_function.py b/lambda_function.py index abc3231..eb74c57 100644 --- a/lambda_function.py +++ b/lambda_function.py @@ -15,17 +15,20 @@ def lambda_handler(event, context): os.environ['PATH'] += ":/var/task/texlive/2017/bin/x86_64-linux/" os.environ['HOME'] = "/tmp/latex/" + os.environ['PERL5LIB'] = "/var/task/texlive/2017/tlpkg/TeXLive/" + os.chdir("/tmp/latex/") # Run pdflatex... - for i in [1, 2]: - r = subprocess.run(["/var/task/texlive/2017/bin/x86_64-linux/pdflatex", - "-interaction=batchmode", - "-output-directory=/tmp/latex", - "document.tex"], - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT) - print(r.stdout.decode('utf_8')) + r = subprocess.run(["latexmk", + "-verbose", + "-interaction=batchmode", + "-pdf", + "-output-directory=/tmp/latex", + "document.tex"], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + print(r.stdout.decode('utf_8')) # Read "document.pdf"... with open("document.pdf", "rb") as f: diff --git a/make.jl b/make.jl index 50147f1..73c9ded 100644 --- a/make.jl +++ b/make.jl @@ -3,7 +3,7 @@ module MakeLatexLambda using JSON using AWSCore using AWSS3 -#using AWSLambda +using AWSLambda using InfoZIP function all() @@ -62,10 +62,13 @@ test_zip = base64encode(create_zip("document.tex" => # Test latex in local docker image. function localtest() + write("test_input.zip.base64", test_zip) pycmd = """ import lambda_function import json - out = lambda_function.lambda_handler({'input': '$test_zip'}, {}) + import base64 + out = lambda_function.lambda_handler( + {'input': open('/var/host/test_input.zip.base64').read()}, {}) with open('/var/host/test_output.json', 'w') as f: f.write(json.dumps(out)) """