From 3b86473f980bfb1c6b226a6643937cd379b6ec78 Mon Sep 17 00:00:00 2001 From: Christophe Benz Date: Mon, 24 Jun 2019 17:02:34 +0200 Subject: [PATCH] Fix Dockerfile and PDF generation --- Dockerfile | 24 +++++++++++------------- validata_ui/views.py | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index daddab0..f2be5c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,25 +6,23 @@ EXPOSE 5000 RUN pip install --no-cache-dir gunicorn==19.9.0 RUN apt-get update && \ - apt-get install --yes chromium=73.0.3683.75-1~deb9u1 + apt-get install --yes --no-install-recommends chromium=73.0.3683.75-1~deb9u1 -ARG user=jenkins -ARG group=jenkins ARG uid=1000 ARG gid=1000 -RUN groupadd -g ${gid} ${group} && \ - useradd -u ${uid} -g ${gid} --no-create-home --shell /bin/bash ${user} +RUN groupadd -g ${gid} validata && \ + useradd -u ${uid} -g ${gid} --create-home --shell /bin/bash validata -WORKDIR /app +# Cf https://bugs.chromium.org/p/chromium/issues/detail?id=638180 and https://blog.ineat-conseil.fr/2018/08/executer-karma-avec-chromeheadless-dans-un-conteneur-docker/ +USER validata -COPY requirements.txt . -RUN pip install --no-cache-dir --requirement requirements.txt +WORKDIR /app -COPY . . -RUN pip install --no-cache-dir --editable . +COPY --chown=validata:validata requirements.txt . +RUN pip install --no-cache-dir --user --requirement requirements.txt --no-warn-script-location -# Cf https://bugs.chromium.org/p/chromium/issues/detail?id=638180 -USER ${user} +COPY --chown=validata:validata . . +RUN pip install --no-cache-dir --user --editable . -CMD gunicorn --bind 0.0.0.0:5000 validata_ui:app \ No newline at end of file +CMD gunicorn --workers 4 --bind 0.0.0.0:5000 validata_ui:app diff --git a/validata_ui/views.py b/validata_ui/views.py index 8407bb9..886788c 100644 --- a/validata_ui/views.py +++ b/validata_ui/views.py @@ -478,7 +478,7 @@ def pdf_report(): tmp_pdf_report = Path(tmpfile.name) # Use chromium headless to generate PDF from validation report page - cmd = ['chromium', '--headless', '--disable-gpu', + cmd = ['chromium', '--headless', '--no-sandbox', '--print-to-pdf={}'.format(str(tmp_pdf_report)), validation_url] result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) if result.returncode != 0: -- GitLab