Skip to content
Snippets Groups Projects
Commit 826287b3 authored by Guillaume Samson's avatar Guillaume Samson
Browse files

Add an image for swh-web service

Related to sysadm-environment#4812
parent d5c604f9
No related branches found
No related tags found
1 merge request!21Add an image for swh-web service
# Deeply inspired from the Dockerfile of the swh-storage project
FROM python:3.10-bullseye
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get install -y libcmph-dev librdkafka-dev && \
apt clean && \
addgroup --gid 1000 swh && \
useradd --gid 1000 --uid 1000 -m -d /srv/swh swh && \
mkdir -p /etc/softwareheritage /var/log/softwareheritage/webapp && \
chown swh:swh /var/log/softwareheritage/webapp
USER swh
WORKDIR /srv/swh
COPY --chown=swh:swh requirements-frozen.txt /srv/swh
COPY --chown=swh:swh entrypoint.sh /srv/swh
ENV PYTHONPATH=/srv/swh
ENV PATH=/srv/swh/.local/bin:$PATH
RUN chmod u+x /srv/swh/entrypoint.sh && \
/usr/local/bin/python -m pip install --upgrade pip && \
pip install --no-cache-dir -r requirements-frozen.txt && \
pip install gunicorn
ENV SWH_CONFIG_FILENAME=/etc/softwareheritage/config.yml
ENV PORT 5004
EXPOSE $PORT
ENV THREADS 2
ENV WORKERS 2
ENV TIMEOUT 3600
ENV DJANGO_SETTINGS_MODULE swh.web.settings.production
ENV SWH_MAIN_PACKAGE swh.web
ENTRYPOINT ["/srv/swh/entrypoint.sh"]
#!/bin/bash
set -e
case "$1" in
"shell")
exec bash -i
;;
"cron")
wait-for-it swh-web:5004 -s --timeout=0
echo "Start periodic save code now refresh statuses routine (in background)"
exec sh -c 'trap exit TERM INT; while :; do
(date && django-admin refresh_savecodenow_statuses \
--settings=${DJANGO_SETTINGS_MODULE} 2>&1)
sleep 15 &
wait ${!}
done'
;;
*)
echo "starting the swh-web server"
# run gunicorn workers as in production otherwise
exec gunicorn \
--bind 0.0.0.0:${PORT} \
--threads ${THREADS} \
--workers ${WORKERS} \
--timeout ${TIMEOUT} \
--access-logfile '-' \
--env DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} \
--config 'python:swh.web.gunicorn_config' \
'django.core.wsgi:get_wsgi_application()'
esac
swh.web
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment