Optim. Repo Structure

This commit is contained in:
2024-10-30 15:32:08 +01:00
parent 414c18ef08
commit 53bc4ac219
14 changed files with 31 additions and 22 deletions

60
utils/mgmt/Dockerfile Normal file
View File

@ -0,0 +1,60 @@
# Agenten Plattform
#
# (c) 2024 Magnus Bender
# Institute of Humanities-Centered Artificial Intelligence (CHAI)
# Universitaet Hamburg
# https://www.chai.uni-hamburg.de/~bender
#
# source code released under the terms of GNU Public License Version 3
# https://www.gnu.org/licenses/gpl-3.0.txt
FROM ubuntu:24.04
ARG H_GID
ARG H_UID
ARG PIP_REQ_FILE
RUN apt update && \
apt install -y bash \
build-essential \
git \
curl \
ca-certificates \
python3-dev \
python3-pip
RUN DEBIAN_FRONTEND=noninteractive TZ=Europe/Berlin apt-get install -y tzdata \
&& cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
&& echo "Europe/Berlin" > /etc/timezone
RUN apt-get install -y vim htop \
nginx supervisor \
&& rm -rf /var/lib/apt/lists
# sytem and user setup
RUN ln -s /usr/bin/python3 /usr/local/bin/python \
&& addgroup --gid $H_GID user \
&& adduser user --uid $H_UID --ingroup user --gecos "" --home /home/user/ --disabled-password
RUN mkdir -p /ums-agenten/plattform/ && mkdir -p /ums-agenten/persist/
COPY ./utils/mgmt/$PIP_REQ_FILE /ums-agenten/requirements.txt
RUN pip3 install --break-system-packages --no-cache-dir -r /ums-agenten/requirements.txt \
&& pip3 freeze > /ums-agenten/requirements.txt
# nginx settings and startup
COPY ./utils/mgmt/supervisor.conf /etc/supervisor/supervisord.conf
COPY ./utils/mgmt/nginx.conf /etc/nginx/nginx.conf
COPY ./utils/mgmt/app.conf /etc/nginx/sites-enabled/default
# install the code of the repo
COPY ./utils/setup.py /ums-agenten/plattform/
RUN pip3 install --break-system-packages -e /ums-agenten/plattform/
WORKDIR /ums-agenten/plattform/ums/
COPY --chown=user:user ./ums/ /ums-agenten/plattform/ums/
COPY --chown=user:user ./web/ /ums-agenten/plattform/web/
# run nginx and uvicorn
ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]

45
utils/mgmt/app.conf Normal file
View File

@ -0,0 +1,45 @@
# Agenten Plattform
#
# (c) 2024 Magnus Bender
# Institute of Humanities-Centered Artificial Intelligence (CHAI)
# Universitaet Hamburg
# https://www.chai.uni-hamburg.de/~bender
#
# source code released under the terms of GNU Public License Version 3
# https://www.gnu.org/licenses/gpl-3.0.txt
server {
listen 80 default_server;
server_name _;
root /ums-agenten/plattform/web/public/;
index index.html;
location = / {
server_name_in_redirect off;
port_in_redirect off;
absolute_redirect off;
return 303 /index;
}
location / {
try_files $uri $uri/ @dynamic;
}
location @dynamic {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
proxy_buffering off;
proxy_pass http://unix:/tmp/uvicorn.sock;
}
}

57
utils/mgmt/nginx.conf Normal file
View File

@ -0,0 +1,57 @@
# Agenten Plattform
#
# (c) 2024 Magnus Bender
# Institute of Humanities-Centered Artificial Intelligence (CHAI)
# Universitaet Hamburg
# https://www.chai.uni-hamburg.de/~bender
#
# source code released under the terms of GNU Public License Version 3
# https://www.gnu.org/licenses/gpl-3.0.txt
user user;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log off;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

View File

@ -0,0 +1,31 @@
annotated-types==0.7.0
anyio==4.6.0
certifi==2024.8.30
charset-normalizer==3.3.2
click==8.1.7
fastapi==0.115.0
h11==0.14.0
httptools==0.6.1
idna==3.10
Jinja2==3.1.4
MarkupSafe==2.1.5
pdoc==14.7.0
pydantic==2.9.2
pydantic_core==2.23.4
Pygments==2.18.0
python-dotenv==1.0.1
python-multipart==0.0.12
PyYAML==6.0.2
requests==2.32.3
setuptools==68.1.2
sniffio==1.3.1
starlette==0.38.6
supervisor==4.2.5
tqdm==4.66.5
typing_extensions==4.12.2
urllib3==2.2.3
uvicorn==0.31.0
uvloop==0.20.0
watchfiles==0.24.0
websockets==13.1
wheel==0.42.0

View File

@ -0,0 +1,17 @@
# Agenten Plattform
#
# (c) 2024 Magnus Bender
# Institute of Humanities-Centered Artificial Intelligence (CHAI)
# Universitaet Hamburg
# https://www.chai.uni-hamburg.de/~bender
#
# source code released under the terms of GNU Public License Version 3
# https://www.gnu.org/licenses/gpl-3.0.txt
# non frozen dependecies, to use latest
requests
tqdm
pdoc
fastapi
uvicorn[standard]
python-multipart

View File

@ -0,0 +1,43 @@
# Agenten Plattform
#
# (c) 2024 Magnus Bender
# Institute of Humanities-Centered Artificial Intelligence (CHAI)
# Universitaet Hamburg
# https://www.chai.uni-hamburg.de/~bender
#
# source code released under the terms of GNU Public License Version 3
# https://www.gnu.org/licenses/gpl-3.0.txt
[supervisord]
nodaemon=true
user=root
logfile=/dev/stdout
logfile_maxbytes = 0
[program:setup]
command=/bin/sh -c "chown user:user -R /ums-agenten"
user=root
autostart=true
autorestart=false
[fcgi-program:uvicorn]
socket=unix:///tmp/uvicorn.sock
environment=SERVE=true
command=/usr/local/bin/uvicorn ums.management.main:app --uds /tmp/uvicorn.sock --proxy-headers
numprocs=4
process_name=uvicorn-%(process_num)d
user=user
autostart=true
autorestart=true
priority=10
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
priority=20