This post. Related to this repo. Template boilerplate from repo.
The purpose is to build an hello world application to manage boardgames for Django discovery and exploratory exercise to determine best framework to use.
Before proceeding let s consider the Django version. Here I selected 3.1 which will be maintained until end of 2022.
3.2 next LTS will soon be available and should be migrated asap when done. ANother valid option should be using previous LTS 2.2 before switch to 3.2.
Consider djangoproject Supported versions before starting.
$ sudo docker-compose run web python manage.py makemigrations
$ sudo docker-compose run web python manage.py migrate
Uses the default Django development server.
-
Rename .env.dev-sample to .env.dev.
-
Update the environment variables in the docker-compose.yml and .env.dev files.
-
Build the images and run the containers:
$ docker-compose up -d --build
or
$ sudo docker-compose up -d --build
-
create a superuser (admin user)
sudo docker-compose run web python manage.py createsuperuser
Test it out at [http://localhost:8000](http://localhost:8000). The "app" folder is mounted into the container and your code changes apply automatically.
Also test the Django admin funcionalities http://localhost:8000/admin](http://localhost:8000/admin).
App is published using the Django built in server capabilities. Not for production use, with the runserver option like this:
```sh
python manage.py runserver 0.0.0.0:8000
```
Start with looking at the logs like this :
$ docker-compose logs -f
or
$ sudo docker-compose logs -f
To restart use
$ docker-compose down -v
before rebuilding (to drop db and rebuild it if passwords database names changes).
Uses gunicorn + nginx.
-
Rename .env.prod-sample to .env.prod and .env.prod.db-sample to .env.prod.db. Update the environment variables.
-
Build the images and run the containers:
$ docker-compose -f docker-compose.prod.yml up -d --build
or
$ sudo docker-compose -f docker-compose.prod.yml up -d --build
Test it out at http://localhost:1337. No mounted folders. To apply changes, the image must be re-built.
App is published using nginx gunicorn webserver, may be used for production use.
python manage.py runserver 0.0.0.0:8000