diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2c84082 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3-buster + +ENV PYTHONUNBUFFERED 1 + +RUN mkdir /code +WORKDIR /code + +RUN apt update && \ + apt install -y gettext nginx uwsgi uwsgi-plugin-python3 && \ + rm -rf /var/lib/apt/lists/* + +COPY requirements.txt /code/ +RUN pip install -r requirements.txt + +COPY . /code/ + +ENTRYPOINT ["/code/entrypoint.sh"] +EXPOSE 8000 diff --git a/README.md b/README.md index 37e3086..c398e50 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,20 @@ ainsi qu'un user med et un mot de passe associé. Voici les étapes à éxecuter pour mysql : ```SQL -CREATE DATABASE club-med; -CREATE USER 'club-med'@'localhost' IDENTIFIED BY 'password'; -GRANT ALL PRIVILEGES ON club-med.* TO 'club-med'@'localhost'; +CREATE DATABASE med; +CREATE USER 'med'@'localhost' IDENTIFIED BY 'password'; +GRANT ALL PRIVILEGES ON med.* TO 'med'@'localhost'; FLUSH PRIVILEGES; ``` +Et pour postgresql : + +```SQL +CREATE DATABASE med; +CREATE USER med WITH PASSWORD 'password'; +GRANT ALL PRIVILEGES ON DATABASE med TO med; +``` + ## Exemple de groupes de droits ``` diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..3af5810 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +python manage.py compilemessages +python manage.py makemigrations +sleep 2 +python manage.py migrate + +# TODO: use uwsgi in production +python manage.py runserver 0.0.0.0:8000 diff --git a/med/settings_local.example.py b/med/settings_local.example.py index 214c600..f0d61c3 100644 --- a/med/settings_local.example.py +++ b/med/settings_local.example.py @@ -32,10 +32,22 @@ DEBUG = True DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'club-med', - 'USER': 'club-med', - 'PASSWORD': 'CHANGE ME !!!', - 'HOST': 'localhost', - }, + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'med', + 'USER': 'med', + 'PASSWORD': 'password_to_store_in_env', + 'HOST': 'db', + 'PORT': '', + } } + +# or MySQL database for Zamok +# DATABASES = { +# 'default': { +# 'ENGINE': 'django.db.backends.mysql', +# 'NAME': 'club-med', +# 'USER': 'club-med', +# 'PASSWORD': 'CHANGE ME !!!', +# 'HOST': 'localhost', +# }, +# } \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c30b5b1..651bd3a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ django-reversion==3.0.3 python-stdnum==1.10 djangorestframework==3.9.2 pyyaml==3.13 -coreapi==2.3.3 \ No newline at end of file +coreapi==2.3.3 +psycopg2