mirror of
https://github.com/norohind/SquadsActivityMonitor.git
synced 2025-04-04 17:30:01 +03:00
Dockerized
This commit is contained in:
parent
c928110c6e
commit
56bbbb5dfa
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@ -0,0 +1,10 @@
|
||||
*sqlite3
|
||||
uwsgi.ini
|
||||
start*.bash
|
||||
__pycache__
|
||||
venv
|
||||
.git
|
||||
uwsgi.ini
|
||||
start.bash
|
||||
Dockerfile
|
||||
squads_stat_cache.sqlite3
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,3 +1,9 @@
|
||||
*sqlite3
|
||||
uwsgi.ini
|
||||
start*.bash
|
||||
__pycache__
|
||||
venv
|
||||
.git
|
||||
uwsgi.ini
|
||||
start.bash
|
||||
squads_stat_cache.sqlite3
|
||||
|
27
Dockerfile
Normal file
27
Dockerfile
Normal file
@ -0,0 +1,27 @@
|
||||
FROM python:3.11-slim as builder
|
||||
WORKDIR /app
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN apt update && apt install -y gcc
|
||||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
|
||||
|
||||
FROM python:3.11-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE 1
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
|
||||
RUN useradd --no-create-home --system user
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/wheels /wheels
|
||||
COPY --from=builder /app/requirements.txt .
|
||||
|
||||
RUN pip install --no-cache /wheels/*
|
||||
USER user
|
||||
COPY . .
|
||||
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
14
entrypoint.sh
Executable file
14
entrypoint.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
echo "Generating uwsgi config"
|
||||
python3 generate_uswgi_config.py
|
||||
|
||||
if [ "$IS_WEB" = "true" ]; then
|
||||
echo "Running web"
|
||||
exec uwsgi -c /tmp/uwsgi.ini
|
||||
fi
|
||||
|
||||
echo "Running collector"
|
||||
exec python main.py $@
|
@ -4,35 +4,26 @@ template = """
|
||||
[uwsgi]
|
||||
master = 1
|
||||
vacuum = true
|
||||
socket = 127.0.0.1:8082
|
||||
socket = 0.0.0.0:8082
|
||||
enable-threads = true
|
||||
die-on-term = true
|
||||
thunder-lock = true
|
||||
threads = {threads}
|
||||
processes = {processes}
|
||||
virtualenv = {venv}
|
||||
wsgi-file = {wsgi_file}
|
||||
chdir = {project_dir}
|
||||
uid = {user}
|
||||
gid = {group}"""[1:]
|
||||
need-app = true
|
||||
chdir = {project_dir}"""[1:]
|
||||
|
||||
project_dir = os.path.dirname(os.path.abspath(__file__)) # current dir
|
||||
venv_path = os.path.join(project_dir, 'venv')
|
||||
wsgi_file = os.path.join(project_dir, 'web.py')
|
||||
|
||||
cpu_count = os.cpu_count()
|
||||
process_count = cpu_count
|
||||
|
||||
user = 'user2'
|
||||
group = user
|
||||
|
||||
config = template.format(threads=cpu_count,
|
||||
processes=process_count,
|
||||
venv=venv_path,
|
||||
wsgi_file=wsgi_file,
|
||||
project_dir=project_dir,
|
||||
user=user,
|
||||
group=group)
|
||||
project_dir=project_dir)
|
||||
|
||||
with open('uwsgi.ini', 'w') as file:
|
||||
with open('/tmp/uwsgi.ini', 'w') as file:
|
||||
file.write(config)
|
||||
|
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user