Skip to content

Commit

Permalink
Moving from uwsgi to gunicorn
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C committed Nov 9, 2021
1 parent 12a02a2 commit ed8dc70
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
14 changes: 5 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
FROM python:3.6-slim
FROM tiangolo/meinheld-gunicorn-flask:python3.8-alpine3.11

RUN apt update && apt install -y build-essential
RUN groupadd --gid 1000 sonar-exporter
RUN useradd --uid 1000 --gid 1000 --create-home sonar-exporter
WORKDIR /home/sonar-exporter
USER sonar-exporter
COPY . .
RUN pip3.6 install -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 9119
ENTRYPOINT [ "/bin/bash", "entrypoint.sh" ]
RUN adduser --disabled-password 1001
RUN chown -R 1001 .
USER 1001
6 changes: 6 additions & 0 deletions gunicorn_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
loglevel = "info"
errorlog = "-" # stderr
accesslog = "-" # stdout
worker_tmp_dir = "/dev/shm"
graceful_timeout = 120
timeout = 120
3 changes: 0 additions & 3 deletions entrypoint.sh → prestart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ fi
if [ $SONAR_PASSWORD ]; then
sed -i "s/password/$SONAR_PASSWORD/g" config.ini
fi

# Run exporter
.local/bin/uwsgi --http 0.0.0.0:${SONAR_EXPORTER_PORT:-9119} --wsgi-file main.py --callable app
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Workaround this issue: https://github.com/benoitc/gunicorn/issues/2564
gunicorn==20.0.4
prometheus-client==0.6.0
requests==2.21.0
uwsgi==2.0.20
flask==2.0.2
3 changes: 3 additions & 0 deletions sonar/data/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def standardize_project_info(project, sonar):
params = {'projectKey': project_key}

response = sonar.req.do_get(url=url, params=params)
if response.status_code != 200:
print(response.text)
response.raise_for_status()
raw_data = response.json()

if 'errors' in raw_data:
Expand Down

0 comments on commit ed8dc70

Please sign in to comment.