Skip to content

Commit

Permalink
Implement GUNICORN_* environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
pnedkov committed Dec 23, 2023
1 parent 8501dd2 commit f0e84f6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5000

ENV WORKERS 2
ENV IP_API false
ENV FLASK_ENV production

ENTRYPOINT exec gunicorn -w $WORKERS -b 0.0.0.0:5000 ipget:app
CMD ["gunicorn", "-c", "gunicorn.py", "ipget:app"]
8 changes: 5 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ version: '3.8'

services:
ipget:
image: prestigen/ipget:0.0.1
image: prestigen/ipget:0.0.2
hostname: ipget
environment:
- WORKERS=4
- GUNICORN_SERVER= # default: ipget
- GUNICORN_BIND= # default: "0.0.0.0:5000"
- GUNICORN_WORKERS= # default: cores * 2 + 1
- GUNICORN_THREADS= # default: 1
- IP_API=false
- FLASK_ENV=production
restart: always

nginx:
Expand Down
2 changes: 1 addition & 1 deletion ipget/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.2
9 changes: 9 additions & 0 deletions ipget/gunicorn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import gunicorn
import os
import multiprocessing

gunicorn.SERVER = os.getenv("GUNICORN_SERVER") or "ipget"
bind = os.getenv("GUNICORN_BIND") or "0.0.0.0:5000"
workers = os.getenv("GUNICORN_WORKERS") or multiprocessing.cpu_count() * 2 + 1
threads = os.getenv("GUNICORN_THREADS") or 1
disable_redirect_access_to_syslog = True
1 change: 1 addition & 0 deletions resources/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ http {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass_header Server;
}

}
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

gunicorn -w ${WORKERS:-2} -b 0.0.0.0:5000 ipget.ipget:app
gunicorn -c ipget/gunicorn.py ipget.ipget:app

0 comments on commit f0e84f6

Please sign in to comment.