diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d7563a5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,50 @@ +FROM docker.io/python:3.12.10-alpine3.21 + +ENV \ + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + # python: + PYTHONFAULTHANDLER=1 \ + PYTHONUNBUFFERED=1 \ + PYTHONHASHSEED=random \ + PYTHONDONTWRITEBYTECODE=1 + +RUN apk add --update --no-cache zlib-dev libxml2-dev libxslt-dev libmemcached-dev \ + build-base gcc make alpine-sdk musl-dev postgresql-dev openldap-dev \ + py3-distutils-extra py3-distutils-extra-pyc shadow python3-dev linux-headers pcre-dev + +ENV VIRTUAL_ENV=/venv + +ENV DJANGO_CONFIGURATION=production + +ENV \ + # pip: + PIP_NO_CACHE_DIR=off \ + PIP_DISABLE_PIP_VERSION_CHECK=on \ + PIP_DEFAULT_TIMEOUT=100 + + +RUN pip install --upgrade pip wheel +RUN python3 -m venv $VIRTUAL_ENV + +COPY requirements.txt . +RUN . /venv/bin/activate && pip install -r requirements.txt + +RUN mkdir -p /app +COPY ./ /app/ + +WORKDIR /app + +RUN . /venv/bin/activate && \ + DJANGO_SECRET_KEY=dummy \ + DJANGO_STATIC_ROOT=/app/static ./manage.py collectstatic --no-input + +RUN groupadd --gid 1001 app \ + && useradd --home-dir /app --shell /bin/bash --gid app --uid 1001 app + +RUN chown -R app:app ./ + +USER app + +ENV PATH="/venv/bin:$PATH" + diff --git a/ipv6ula/settings.py b/ipv6ula/settings.py index ab27519..12a7d55 100644 --- a/ipv6ula/settings.py +++ b/ipv6ula/settings.py @@ -140,7 +140,7 @@ USE_TZ = True STATIC_URL = '/static/' STATICFILES_DIRS = [ ] -STATIC_ROOT = "/home/app/app/static" +STATIC_ROOT = "/app/static" AUTHENTICATION_BACKENDS = [ diff --git a/requirements.txt b/requirements.txt index 29cce86..8d4dd79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,5 @@ django==3.1.4 django-auth-ldap psycopg2 django-crispy-forms +setuptools +uwsgi diff --git a/uwsgiconfig/app.ini b/uwsgiconfig/app.ini new file mode 100644 index 0000000..7d9a156 --- /dev/null +++ b/uwsgiconfig/app.ini @@ -0,0 +1,12 @@ +[uwsgi] +socket = /app/uwsgi/uwsgi.sock +chdir = /app +venv = /venv +wsgi-file = ipv6ula/wsgi.py +processes = 4 +threads = 2 +chmod-socket = 666 +vacuum = true +plugins = python3 +uid = app +gid = app