90 lines
2.2 KiB
Markdown
90 lines
2.2 KiB
Markdown
# taal-academie.arree.bzh
|
|
|
|
Project structure :
|
|
|
|
```
|
|
.
|
|
├── django
|
|
│ ├── Dockerfile
|
|
│ ├── requirements.txt
|
|
│ └── src
|
|
│ ├── config
|
|
│ ├── development.env
|
|
│ ├── home
|
|
│ ├── local.env
|
|
│ ├── manage.py
|
|
│ ├── pages
|
|
│ ├── production.env
|
|
│ └── workshops
|
|
├── compose.dev.yml
|
|
├── compose.local.yml
|
|
├── compose.prod.yml
|
|
├── compose.yml
|
|
├── nginx
|
|
│ ├── default.conf
|
|
│ └── Dockerfile
|
|
└── README.md
|
|
```
|
|
|
|
## Deployment with Nerdctl Compose
|
|
|
|
Can be used as well in Nerdctl root or [rootless](https://docs.docker.com/engine/security/rootless/) mode.
|
|
|
|
There are three profiles :
|
|
|
|
* Development : with only the database
|
|
* Local : for local testing of the production stack
|
|
* Production : Final deployment on the server
|
|
|
|
### Development
|
|
|
|
To run the development profile from the project `django/src` directory :
|
|
|
|
```
|
|
$ ( cd ../.. && nerdctl compose -f compose.yml -f compose.dev.yml up -d postgres )
|
|
```
|
|
|
|
Then when calling the `manage.py` script we need to pass `DJANGO_ENV` to load `src/dev.env`, like in the
|
|
following example to start the Django development server :
|
|
|
|
```
|
|
$ DJANGO_ENV=dev python manage.py runserver
|
|
```
|
|
|
|
To not have to pass this for each `manage.py` execution you may export `DJANGO_ENV` from your `.bashrc` :
|
|
|
|
```
|
|
$ echo -e "\n# Django development\nexport DJANGO_ENV=dev" >> ~/.bashrc
|
|
```
|
|
|
|
> Need to restart the session !
|
|
|
|
### Local
|
|
|
|
To run the local profile from the project `django/src` directory :
|
|
|
|
```
|
|
$ ( cd ../.. && nerdctl compose -f compose.yml -f compose.local.yml up -d )
|
|
```
|
|
|
|
### Production
|
|
|
|
To run the production profile from the directory where the `compose.yml` file lives :
|
|
|
|
```
|
|
$ nerdctl compose -f compose.yml -f compose.prod.yml up -d
|
|
```
|
|
|
|
At the first launch, it is advised to run the Deployment checklist from `manage.py` to check if there are some security
|
|
improvements :
|
|
|
|
```
|
|
$ nerdctl exec -it django_taal-academiearreebzh python /django/manage.py check --deploy
|
|
```
|
|
|
|
Then create an admin user for the Django admin panel :
|
|
|
|
```
|
|
$ nerdctl exec -it django_taal-academiearreebzh python /django/manage.py createsuperuser
|
|
```
|