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
5 changed files
with
117 additions
and
2 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
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,30 @@ | ||
# build env | ||
FROM node:16-alpine as build | ||
|
||
COPY ./frontend /frontend | ||
WORKDIR /frontend | ||
RUN npm install && npm run build && rm -rf node_modules | ||
|
||
# prod env | ||
FROM python:3.9-slim-buster | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y libmagic-dev \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /backend | ||
|
||
COPY pyproject.toml poetry.lock /backend/ | ||
COPY gunicorn.conf.py /backend | ||
COPY app /backend/app | ||
|
||
RUN pip3 install poetry && poetry config virtualenvs.create false && poetry install --no-dev | ||
|
||
COPY --from=build /frontend /backend/frontend | ||
|
||
ENV PORT 8000 | ||
|
||
EXPOSE $PORT | ||
|
||
CMD gunicorn -k uvicorn.workers.UvicornWorker 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: "3.7" | ||
services: | ||
spamassassin: | ||
container_name: eml_analyzer_spamassassin | ||
image: instantlinux/spamassassin:3.4.6-1 | ||
ports: | ||
- ${PORT_SPAMASSASSIN:-783}:783 | ||
restart: always | ||
|
||
eml_analyzer: | ||
container_name: eml_analyzer_app | ||
build: | ||
context: ./ | ||
dockerfile: app.Dockerfile | ||
ports: | ||
- ${PORT:-8000}:8000 | ||
environment: | ||
- VIRUSTOTAL_API_KEY=${VIRUSTOTAL_API_KEY} | ||
- URLSCAN_API_KEY=${URLSCAN_API_KEY} | ||
- INQUEST_API_KEY=${INQUEST_API_KEY} | ||
- SPAMASSASSIN_HOST=spamassassin | ||
- SPAMASSASSIN_PORT=${PORT_SPAMASSASSIN:-783} | ||
restart: always | ||
depends_on: | ||
- spamassassin |
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) |