mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-08-19 13:43:40 +00:00
feat: ✨ Add dev docker support
Dockerfile and docker-compose files are now included in directory. They start a db, migrate, create a superuser if it doesn't already exists and start the server
This commit is contained in:
parent
889f70738b
commit
43b6a2cdf2
4 changed files with 164 additions and 0 deletions
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM python:3
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends gettext-base libpq-dev
|
||||
WORKDIR /code
|
||||
COPY requirements.txt /code/
|
||||
COPY postgresql-requirements.txt /code/
|
||||
COPY dev-requirements.txt /code/
|
||||
RUN pip install -r requirements.txt
|
||||
RUN pip install -r postgresql-requirements.txt
|
||||
RUN pip install -r dev-requirements.txt
|
||||
COPY . /code/
|
||||
CMD ./docker/docker-entrypoint.sh
|
31
docker-compose.yml
Normal file
31
docker-compose.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
version: "3"
|
||||
|
||||
volumes:
|
||||
database_data:
|
||||
driver: local
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:latest
|
||||
volumes:
|
||||
- database_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_DB=postgres
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
|
||||
re2o:
|
||||
build: .
|
||||
volumes:
|
||||
- .:/code
|
||||
ports:
|
||||
- "8000:8000"
|
||||
depends_on:
|
||||
- db
|
||||
environment:
|
||||
- POSTGRES_DB=postgres
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- SUPERUSER_LOGIN=admin
|
||||
- SUPERUSER_PASS=admin
|
||||
- SUPERUSER_EMAIL=admin@example.net
|
20
docker/docker-entrypoint.sh
Executable file
20
docker/docker-entrypoint.sh
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
cat docker/settings_local.template.py | envsubst > re2o/settings_local.py
|
||||
|
||||
AUTOMIGRATE=${AUTOMIGRATE:-yes}
|
||||
|
||||
if [ "$AUTOMIGRATE" != "skip" ]; then
|
||||
python3 manage.py migrate --noinput
|
||||
fi
|
||||
|
||||
cat <<EOF | python manage.py shell
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
User.objects.filter(pseudo='$SUPERUSER_LOGIN').exists() or \
|
||||
User.objects.create_superuser(pseudo='$SUPERUSER_LOGIN', email='$SUPERUSER_EMAIL', password='$SUPERUSER_PASS', surname='$SUPERUSER_LOGIN')
|
||||
EOF
|
||||
python manage.py runserver 0.0.0.0:8000
|
101
docker/settings_local.template.py
Normal file
101
docker/settings_local.template.py
Normal file
|
@ -0,0 +1,101 @@
|
|||
# coding: utf-8
|
||||
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
||||
# se veut agnostique au réseau considéré, de manière à être installable en
|
||||
# quelques clics.
|
||||
#
|
||||
# Copyright © 2017 Gabriel Détraz
|
||||
# Copyright © 2017 Lara Kermarec
|
||||
# Copyright © 2017 Augustin Lemesle
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
"""re2o.settings_locale
|
||||
The file with all the available options for a locale configuration of re2o
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# A secret key used by the server.
|
||||
SECRET_KEY = "=0u1d+gi6r06+r4gmrtdg6dhsi0mc7v39a37di4m5cfqt2aro2"
|
||||
|
||||
# AES key for secret key encryption.
|
||||
# The length must be a multiple of 16
|
||||
AES_KEY = "gnbe3elnujzlspzkavgdmqho16zizvek"
|
||||
|
||||
# Should the server run in debug mode ?
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
# A list of admins of the services. Receive mails when an error occurs
|
||||
ADMINS = [("Example", "admin@example.net")]
|
||||
|
||||
# The list of hostname the server will respond to.
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# The time zone the server is runned in
|
||||
TIME_ZONE = "Europe/Paris"
|
||||
|
||||
# The storage systems parameters to use
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': '${POSTGRES_DB}',
|
||||
'USER': '${POSTGRES_USER}',
|
||||
'PASSWORD': '${POSTGRES_PASSWORD}',
|
||||
'HOST': 'db',
|
||||
}
|
||||
}
|
||||
|
||||
# Security settings for secure https
|
||||
# Activate once https is correctly configured
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = False
|
||||
SECURE_BROWSER_XSS_FILTER = False
|
||||
SESSION_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
X_FRAME_OPTIONS = "DENY"
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||
|
||||
# The path where your organization logo is stored
|
||||
LOGO_PATH = "static_files/logo.png"
|
||||
|
||||
# The mail configuration for Re2o to send mails
|
||||
SERVER_EMAIL = "no-reply@example.net" # The mail address to use
|
||||
EMAIL_HOST = "example.net" # The host to use
|
||||
# EMAIL_PORT = MY_EMAIL_PORT # The port to use
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||
|
||||
# Add statiffiles dir that were installed using system packaging
|
||||
# Example to reproduce re2o2.9 behavior
|
||||
# SYSTEM_STATICFILES_DIRS = ("/usr/share/fonts-font-awesome/", "/usr/share/javascript/")
|
||||
SYSTEM_STATICFILES_DIRS = ()
|
||||
|
||||
# Wether to use CDN to retrieve bootstrap, font-aweseome and jquery files
|
||||
# Default to False
|
||||
USE_CDN = True
|
||||
|
||||
# A range of UID to use. Used in linux environement
|
||||
UID_RANGES = {"users": [21001, 30000], "service-users": [20000, 21000]}
|
||||
|
||||
# A range of GID to use. Used in linux environement
|
||||
GID_RANGES = {"posix": [501, 600]}
|
||||
|
||||
# Default gid
|
||||
DEFAULT_GID = 500
|
||||
|
||||
# Some optionnal Re2o Apps
|
||||
OPTIONNAL_APPS_RE2O = ()
|
||||
|
||||
# Some Django apps you want to add in you local project
|
||||
OPTIONNAL_APPS = OPTIONNAL_APPS_RE2O + ()
|
Loading…
Reference in a new issue