diff --git a/apps/swh-graphql/Dockerfile b/apps/swh-graphql/Dockerfile new file mode 100644 --- /dev/null +++ b/apps/swh-graphql/Dockerfile @@ -0,0 +1,34 @@ +# Deeply inspired from the Dockerfile of the swh-graph project +FROM python:3.10-bullseye + +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get install -y libcmph-dev librdkafka-dev && \ + rm -rf /var/lib/dpkg && \ + addgroup --gid 1000 swh && \ + useradd --gid 1000 --uid 1000 -m -d /opt/graphql swh && \ + mkdir /etc/swh + +USER swh +WORKDIR /opt/graphql + +COPY --chown=swh:swh requirements-frozen.txt /opt/graphql +COPY --chown=swh:swh entrypoint.sh /opt/graphql + +ENV PYTHONPATH=/opt/graphql +ENV PATH=/opt/graphql/.local/bin:$PATH + +RUN chmod u+x /opt/graphql/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/swh/config.yml +ENV PORT 5013 +EXPOSE $PORT +ENV THREADS 4 +ENV WORKERS 2 +ENV LOG_LEVEL INFO +ENV TIMEOUT 3600 + +ENTRYPOINT "/opt/graphql/entrypoint.sh" diff --git a/apps/swh-graphql/entrypoint.sh b/apps/swh-graphql/entrypoint.sh new file mode 100644 --- /dev/null +++ b/apps/swh-graphql/entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +case "$1" in +"shell") + exec bash -i + ;; +*) + echo Starting the swh-graphql API server + + exec gunicorn --bind "0.0.0.0:${PORT}" \ + --reload \ + --threads "${THREADS}" \ + --workers "${WORKERS}" \ + --log-level "${LOG_LEVEL}" \ + --timeout "${TIMEOUT}" \ + --config 'python:swh.core.api.gunicorn_config' \ + 'swh.graphql.server:make_app_from_configfile()' + ;; +esac diff --git a/apps/swh-graphql/requirements-frozen.txt b/apps/swh-graphql/requirements-frozen.txt --- a/apps/swh-graphql/requirements-frozen.txt +++ b/apps/swh-graphql/requirements-frozen.txt @@ -1,11 +1,71 @@ -anyio==3.5.0 -ariadne==0.15.1 -asgiref==3.5.1 -click==8.1.3 -graphql-core==3.2.1 -h11==0.13.0 +aiohttp==3.8.1 +aiohttp-utils==3.1.1 +aiosignal==1.2.0 +ariadne==0.14.1 +asgiref==3.4.1 +async-timeout==4.0.2 +attrs==21.4.0 +attrs-strict==1.0.0 +blinker==1.4 +cassandra-driver==3.25.0 +certifi==2021.10.8 +cffi==1.15.0 +charset-normalizer==2.0.12 +click==8.0.1 +confluent-kafka==1.8.2 +Deprecated==1.2.13 +Flask==2.1.2 +frozenlist==1.3.0 +geomet==0.2.1.post1 +graphql-core==3.1.6 +gunicorn==20.1.0 +h11==0.12.0 +hypothesis==6.46.6 idna==3.3 -pkg_resources==0.0.0 -sniffio==1.2.0 -starlette==0.20.0 -typing_extensions==4.2.0 +importlib-metadata==4.11.3 +iniconfig==1.1.1 +iso8601==1.0.2 +itsdangerous==2.1.2 +Jinja2==3.1.2 +MarkupSafe==2.1.1 +mirakuru==2.4.2 +msgpack==1.0.3 +multidict==6.0.2 +mypy-extensions==0.4.3 +packaging==21.3 +pluggy==1.0.0 +port-for==0.6.2 +psutil==5.9.0 +psycopg2==2.9.3 +py==1.11.0 +pycparser==2.21 +pyparsing==3.0.9 +pytest==7.1.2 +pytest-postgresql==3.1.3 +python-dateutil==2.8.2 +python-magic==0.4.25 +python-mimeparse==1.6.0 +PyYAML==6.0 +redis==4.3.1 +requests==2.27.1 +sentry-sdk==1.5.12 +six==1.16.0 +sortedcontainers==2.4.0 +starlette==0.14.2 +swh.core==2.5.0 +swh.counters==0.9.1 +swh.graphql==0.0.1.post1 +swh.journal==1.0.0 +swh.model==6.2.0 +swh.objstorage==1.0.5 +swh.perfecthash==0.1.2 +swh.storage==1.4.0 +tenacity==8.0.1 +tomli==2.0.1 +typing-extensions==3.10.0.2 +urllib3==1.26.9 +uvicorn==0.17.4 +Werkzeug==2.1.2 +wrapt==1.14.1 +yarl==1.7.2 +zipp==3.8.0 diff --git a/apps/swh-graphql/requirements.txt b/apps/swh-graphql/requirements.txt --- a/apps/swh-graphql/requirements.txt +++ b/apps/swh-graphql/requirements.txt @@ -5,3 +5,4 @@ h11 starlette typing-extensions +swh-graphql