feat: run with gunicorn instead of flask
Each worker now uses its own registry instead of the global REGISTRY to avoid duplicate metric registration, since metrics are served from the database.
This commit is contained in:
parent
45823b02e4
commit
0867b13f8f
3 changed files with 17 additions and 7 deletions
11
Dockerfile
11
Dockerfile
|
@ -4,14 +4,16 @@ ENV APP="bc"
|
|||
ENV APP_BASE="/srv"
|
||||
ENV SHELL="/bin/bash"
|
||||
ENV FLASK_APP="${FLASK_APP:-app}"
|
||||
ENV FLASK_RUN_HOST="${FLASK_RUN_HOST:-0.0.0.0}"
|
||||
ENV FLASK_RUN_PORT="${FLASK_RUN_PORT:-5000}"
|
||||
ENV GUNICORN_RUN_HOST="${GUNICORN_RUN_HOST:-0.0.0.0}"
|
||||
ENV GUNICORN_RUN_PORT="${GUNICORN_RUN_PORT:-5000}"
|
||||
ENV PYTHONPATH="${APP_BASE}/env/lib/python3.11/site-packages"
|
||||
ENV PATH="${APP_BASE}/env/bin:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:/home/${APP}/.local/bin"
|
||||
|
||||
ARG CONTAINER_UID="${CONTAINER_UID:-1000}"
|
||||
ARG CONTAINER_GID="${CONTAINER_GID:-1000}"
|
||||
|
||||
ENV GUNICORN_WORKERS="${GUNICORN_WORKERS:-4}"
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install --no-install-recommends -y \
|
||||
curl \
|
||||
|
@ -47,10 +49,11 @@ USER ${APP}
|
|||
|
||||
WORKDIR ${APP_BASE}/${APP}
|
||||
COPY --chown=${APP}:${APP} . ${APP_BASE}/${APP}
|
||||
RUN chmod +x ${APP_BASE}/${APP}/run_gunicorn.sh
|
||||
|
||||
RUN python3 -m venv ${APP_BASE}/env && \
|
||||
${APP_BASE}/env/bin/pip install --no-cache-dir -r requirements.txt && \
|
||||
${APP_BASE}/env/bin/pip install --no-cache-dir psycopg2-binary
|
||||
${APP_BASE}/env/bin/pip install --no-cache-dir psycopg2-binary gunicorn
|
||||
|
||||
RUN rm -rf frontend && \
|
||||
git clone https://gitlab.com/guardianproject-ops/bypass-censorship/portal-frontend.git frontend && \
|
||||
|
@ -58,3 +61,5 @@ RUN rm -rf frontend && \
|
|||
mkdir -p ${APP_BASE}/${APP}/app/static/ui && \
|
||||
cp -r dist/* ${APP_BASE}/${APP}/app/static/ui && \
|
||||
rm -rf frontend /tmp/* /var/tmp/*
|
||||
|
||||
ENTRYPOINT ["./run_gunicorn.sh"]
|
Loading…
Add table
Add a link
Reference in a new issue