Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
234 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# git | ||
.git | ||
|
||
# vscode | ||
.vscode | ||
|
||
# node | ||
**/node_modules | ||
node_modules | ||
|
||
# SQLite | ||
*.db | ||
|
||
# Environments | ||
.env | ||
.venv | ||
|
||
# python | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
**/*.py[cod] | ||
**/*$py.class | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM python:3.9-slim-buster | ||
|
||
WORKDIR /backend | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y whois \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY pyproject.toml poetry.lock README.md /backend/ | ||
COPY abuse_whois /backend/abuse_whois | ||
COPY gunicorn.conf.py /backend/ | ||
|
||
RUN pip install -U pip && \ | ||
pip install poetry \ | ||
&& poetry install --extras api --no-dev | ||
|
||
ENV PORT 8000 | ||
|
||
EXPOSE $PORT | ||
|
||
CMD poetry run gunicorn -k uvicorn.workers.UvicornWorker abuse_whois.api.app:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import multiprocessing | ||
import os | ||
|
||
workers_per_core_str = os.getenv("WORKERS_PER_CORE", "1") | ||
max_workers_str = os.getenv("MAX_WORKERS") | ||
use_max_workers = None | ||
if max_workers_str: | ||
use_max_workers = int(max_workers_str) | ||
web_concurrency_str = os.getenv("WEB_CONCURRENCY", None) | ||
|
||
host = os.getenv("HOST", "0.0.0.0") | ||
port = os.getenv("PORT", "8000") | ||
use_loglevel = os.getenv("LOG_LEVEL", "info") | ||
use_bind = f"{host}:{port}" | ||
|
||
accesslog_var = os.getenv("ACCESS_LOG", "-") | ||
use_accesslog = accesslog_var or None | ||
errorlog_var = os.getenv("ERROR_LOG", "-") | ||
use_errorlog = errorlog_var or None | ||
graceful_timeout_str = os.getenv("GRACEFUL_TIMEOUT", "120") | ||
timeout_str = os.getenv("TIMEOUT", "120") | ||
keepalive_str = os.getenv("KEEP_ALIVE", "5") | ||
|
||
cores = multiprocessing.cpu_count() | ||
workers_per_core = float(workers_per_core_str) | ||
default_web_concurrency = workers_per_core * cores | ||
if web_concurrency_str: | ||
web_concurrency = int(web_concurrency_str) | ||
assert web_concurrency > 0 | ||
else: | ||
web_concurrency = max(int(default_web_concurrency), 2) | ||
if use_max_workers: | ||
web_concurrency = min(web_concurrency, use_max_workers) | ||
|
||
# Gunicorn config variables | ||
loglevel = use_loglevel | ||
workers = web_concurrency | ||
bind = use_bind | ||
errorlog = use_errorlog | ||
accesslog = use_accesslog | ||
graceful_timeout = int(graceful_timeout_str) | ||
timeout = int(timeout_str) | ||
keepalive = int(keepalive_str) |
Oops, something went wrong.