Skip to content

Commit

Permalink
Add MafiAStarLite
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Aug 7, 2023
1 parent 32184fd commit 7df1053
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 0 deletions.
34 changes: 34 additions & 0 deletions MafiAStarLite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM debian:bullseye AS base

ARG BACKEND_PATH=./MafiAStarLite

# Install normal dependencies
RUN apt-get update
RUN apt-get -y --no-install-recommends install uwsgi uwsgi-plugin-python3 python3 python3-pip python3-setuptools pipenv nginx
RUN pip3 install wheel

# Add project code to container
ADD $BACKEND_PATH /app/backend

# Setup backend
RUN cd /app/backend && pipenv install --system --deploy --ignore-pipfile

FROM node:18 AS frontend

# Build frontend
ARG FRONTEND_PATH=./MafiAStarLite-frontend
ADD $FRONTEND_PATH /app/frontend
WORKDIR /app/frontend
RUN npm install
RUN npm run build

FROM base AS final
COPY --from=frontend /app/frontend/dist /app/static
RUN mkdir /app/backend/logs
ADD start.sh /usr/local/bin/run
ADD uwsgi-mafiastar.ini /etc/uwsgi/mafiastar.ini
ADD nginx.conf /etc/nginx/sites-enabled/default

RUN usermod -u 2009 -g 33 -d /app/backend www-data

CMD /usr/local/bin/run
1 change: 1 addition & 0 deletions MafiAStarLite/MafiAStarLite
Submodule MafiAStarLite added at 37bcfe
1 change: 1 addition & 0 deletions MafiAStarLite/MafiAStarLite-frontend
Submodule MafiAStarLite-frontend added at a916f0
19 changes: 19 additions & 0 deletions MafiAStarLite/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# vim: set filetype=conf:

server {
listen 80;
server_name default_server;

try_files $uri /index.html;
root /app/static;

location /admin {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3008;
}

location /api {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3008;
}
}
13 changes: 13 additions & 0 deletions MafiAStarLite/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e
export USER=www-data
export HOME=/home/www-data

# Migrate database and deploy staticfiles
python3 /app/backend/manage.py migrate
python3 /app/backend/manage.py collectstatic --noinput
chown -R www-data:www-data /app/backend/logs

# Start backend with uWSGI
nginx
exec uwsgi /etc/uwsgi/mafiastar.ini
36 changes: 36 additions & 0 deletions MafiAStarLite/uwsgi-mafiastar.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[uwsgi]

procname-master = uwsgi %n
master = true
socket = :3008

plugins = python3

chdir = /app/backend

#home = /opt/tauschen/tauschen-backend/.pyenv
module = MafiAStarLite.wsgi:application
#env = DJANGO_SETTINGS_MODULE=tauschen.settings
env = LANG='C.UTF-8'
env = LC_ALL='C.UTF-8'

; drop privileges
uid = www-data
gid = www-data
umask = 027

; run with at least 2 process but increase up to 8 when needed
processes = 8
cheaper = 2

; reload whenever this config file changes
; %p is the full path of the current config file
touch-reload = %p

; disable uWSGI request logging
disable-logging = true

enable-threads = true

; cron job
cron2 = minute=30,hour=2,unique=1 python3 /app/backend/manage.py updatedb

0 comments on commit 7df1053

Please sign in to comment.