Docker image support for repapp
This commit is contained in:
parent
03f308b087
commit
5ca7e7c663
9 changed files with 107 additions and 5 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
|
@ -1,3 +1,10 @@
|
||||||
|
|
||||||
|
rc_hip/static
|
||||||
|
rc_hip/static/**
|
||||||
|
|
||||||
|
rc_hip/data
|
||||||
|
rc_hip/data/**
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|
|
||||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
FROM python:3-bullseye
|
||||||
|
|
||||||
|
# install nginx
|
||||||
|
RUN apt-get update && apt-get install nginx vim -y --no-install-recommends
|
||||||
|
COPY nginx.default /etc/nginx/sites-available/default
|
||||||
|
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
|
||||||
|
&& ln -sf /dev/stderr /var/log/nginx/error.log
|
||||||
|
|
||||||
|
# copy source and install dependencies
|
||||||
|
RUN mkdir -p /opt/app
|
||||||
|
RUN mkdir -p /opt/app/pip_cache
|
||||||
|
RUN mkdir -p /opt/app/rc_hip
|
||||||
|
|
||||||
|
COPY rc_hip /opt/app/rc_hip
|
||||||
|
RUN rm -f /opt/app/rc_hip/data/db.sqlite3
|
||||||
|
|
||||||
|
WORKDIR /opt/app
|
||||||
|
|
||||||
|
COPY requirements_prod.txt /opt/app/
|
||||||
|
RUN pip install -r requirements_prod.txt --cache-dir /opt/app/pip_cache
|
||||||
|
|
||||||
|
COPY start_server.sh /opt/app/
|
||||||
|
RUN chmod +x /opt/app/start_server.sh
|
||||||
|
|
||||||
|
RUN chown -R www-data:www-data /opt/app
|
||||||
|
|
||||||
|
# start server
|
||||||
|
CMD ["/opt/app/start_server.sh"]
|
||||||
19
README.md
19
README.md
|
|
@ -1,2 +1,21 @@
|
||||||
# RepApp
|
# RepApp
|
||||||
|
|
||||||
Web App um Reparaturtermine zu vereinbaren.
|
Web App um Reparaturtermine zu vereinbaren.
|
||||||
|
|
||||||
|
For documentation see https://makes-hacks-hip.github.io/RepApp/.
|
||||||
|
|
||||||
|
## Build Docker image
|
||||||
|
|
||||||
|
- Build the image: `docker build -t repapp .`
|
||||||
|
- Run the image:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run --rm -d \
|
||||||
|
-p 127.0.0.1:8020:8020 \
|
||||||
|
--name repapp \
|
||||||
|
--env DJANGO_SUPERUSER_USERNAME=suba \
|
||||||
|
--env DJANGO_SUPERUSER_PASSWORD=ThePassword \
|
||||||
|
--env DJANGO_SUPERUSER_EMAIL=noreply@example.com \
|
||||||
|
repapp`
|
||||||
|
```
|
||||||
|
- Open `http://127.0.0.1:8020/` in your browser
|
||||||
|
|
|
||||||
13
nginx.default
Normal file
13
nginx.default
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
server {
|
||||||
|
listen 8020;
|
||||||
|
server_name example.org;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://127.0.0.1:8010;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
}
|
||||||
|
location /static {
|
||||||
|
root /opt/app/rc_hip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,21 +9,28 @@ https://docs.djangoproject.com/en/4.2/topics/settings/
|
||||||
For the full list of settings and their values, see
|
For the full list of settings and their values, see
|
||||||
https://docs.djangoproject.com/en/4.2/ref/settings/
|
https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||||
"""
|
"""
|
||||||
|
import mimetypes
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
mimetypes.add_type("text/css", ".css", True)
|
||||||
|
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
||||||
|
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = 'django-insecure-ura&_-(r(&&b$0s!a=07c@k6c!8=8m7$5(4#w8m@79-e%rn6s*'
|
# SECRET_KEY = 'django-insecure-ura&_-(r(&&b$0s!a=07c@k6c!8=8m7$5(4#w8m@79-e%rn6s*'
|
||||||
|
SECRET_KEY = os.environ.get(
|
||||||
|
"DJANGO_SECRET_KEY", 'django-insecure-ura&_-(r(&&b$0s!a=07c@k6c!8=8m7$5(4#w8m@79-e%rn6s*')
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = os.getenv("DJANGO_DEBUG", 'true').lower() in ('true', '1', 't')
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
@ -77,7 +84,7 @@ WSGI_APPLICATION = 'rc_hip.wsgi.application'
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.sqlite3',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': BASE_DIR / 'db.sqlite3',
|
'NAME': BASE_DIR / 'data' / 'db.sqlite3',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,3 +129,9 @@ STATIC_URL = 'static/'
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
|
||||||
|
CSRF_TRUSTED_ORIGINS = [
|
||||||
|
'https://repapp.rc-hip.de',
|
||||||
|
'http://127.0.0.1:8020'
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,6 @@ from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("repapp/", include("repapp.urls")),
|
path("", include("repapp.urls")),
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
6
requirements_dev.txt
Normal file
6
requirements_dev.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
autopep8==2.0.2
|
||||||
|
Django==4.2
|
||||||
|
pep8==1.7.1
|
||||||
|
pylint==2.17.2
|
||||||
|
pylint-django==2.5.3
|
||||||
|
pylint-plugin-utils==0.7
|
||||||
2
requirements_prod.txt
Normal file
2
requirements_prod.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Django==4.2
|
||||||
|
gunicorn==20.1.0
|
||||||
14
start_server.sh
Normal file
14
start_server.sh
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cd /opt/app/rc_hip
|
||||||
|
|
||||||
|
python manage.py makemigrations --noinput
|
||||||
|
python manage.py migrate --noinput
|
||||||
|
python manage.py collectstatic --noinput
|
||||||
|
|
||||||
|
if [ -n "$DJANGO_SUPERUSER_USERNAME" ] && [ -n "$DJANGO_SUPERUSER_PASSWORD" ] ; then
|
||||||
|
(python manage.py createsuperuser --no-input)
|
||||||
|
fi
|
||||||
|
|
||||||
|
chown -R www-data:www-data /opt/app
|
||||||
|
|
||||||
|
(gunicorn rc_hip.wsgi --user www-data --bind 0.0.0.0:8010 --workers 3) & nginx -g "daemon off;"
|
||||||
Reference in a new issue