Skip to content

Commit

Permalink
don'use dumb-init but use specific puppeteer cache dir
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Nov 23, 2023
1 parent 40b162a commit 750240c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ RUN /app/venv/bin/nodeenv /app/venv/ -C '' -p -n 20.9.0
# upgrade npm & requirements
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
RUN . /app/venv/bin/activate && npm ci && rm /app/*.json
RUN . /app/venv/bin/activate && PUPPETEER_CACHE_DIR=/opt/screamshotter/puppeteer/ npm ci && rm /app/*.json

FROM build as dev

Expand All @@ -104,8 +104,6 @@ COPY --from=build /home/django/.cache/puppeteer /home/django/.cache/puppeteer
COPY src /app/src

RUN mkdir -p /app/static && chown django:django /app/static
ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_x86_64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init

RUN apt-get -qq update && apt-get upgrade -qq -y && \
apt-get clean all && rm -rf /var/apt/lists/* && rm -rf /var/cache/apt/*
Expand All @@ -114,6 +112,4 @@ VOLUME /app/static

USER django

ENTRYPOINT ["dumb-init", "--", "/usr/local/bin/entrypoint.sh"]
CMD gunicorn screamshotter.wsgi:application -w $WORKERS --max-requests $MAX_REQUESTS --timeout `expr $TIMEOUT + 10` --bind 0.0.0.0:8000 --worker-tmp-dir /dev/shm

2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ override_dh_virtualenv:
dh_virtualenv --python /usr/bin/python3 --builtin-venv --install-suffix screamshotter --preinstall "setuptools" --preinstall "wheel"
debian/screamshotter/opt/screamshotter/bin/python debian/screamshotter/opt/screamshotter/bin/nodeenv -C '' -p -n 20.9.0
cp package.json package-lock.json debian/screamshotter/opt/screamshotter/
. ./debian/screamshotter/opt/screamshotter/bin/activate && npm ci --omit=dev --unsafe-perm=true
. ./debian/screamshotter/opt/screamshotter/bin/activate && PUPPETEER_CACHE_DIR=./debian/screamshotter/opt/screamshotter/puppeteer/ npm ci --omit=dev --unsafe-perm=true

.PHONY: override_dh_strip override_dh_shlibdeps
1 change: 1 addition & 0 deletions src/screenshotter/puppeteer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def take_screenshot(url, width=1920, height=1080, waitfor='body', wait_selectors
# We send sentry informations and version : when we use screamshotter as a package, informations are in settings only
with NamedTemporaryFile(suffix='.png') as screenshot_file:
command = subprocess.run([
"PUPPETEER_CACHE_DIR=/opt/screamshotter/puppeteer/",
os.getenv('NODE_BIN_PATH', 'node'),
app_settings.PUPPETEER_JAVASCRIPT_FILEPATH,
'--version',
Expand Down

0 comments on commit 750240c

Please sign in to comment.