Skip to content

Latest commit

 

History

History
111 lines (87 loc) · 4.43 KB

README.md

File metadata and controls

111 lines (87 loc) · 4.43 KB

Starter Kit for Wagtail

This is a starter kit that can be used to launch Django projects with Wagtail. It is an already functional website with articles, tags and categories. The frontend is implemented in Django template language with Bootstrap. The API is also activated to use it as a headless CMS.

Licence

This project is released under the open source MIT licence.

Technologies used

  • Docker + Docker Compose (just "docker-compose up" to get a dev ready environnement)
  • Traefik : Not included in this directory. I use it to proxy the different Docker based projects of my remote dev environement. The SSL certificate is provided by Traefik, so that you will have to modify NGINX configuration if you want HTTPS without Traefik.
  • NGINX : serve static files and proxy uWSGI
  • uWSGI : serve dynamicly generated HTML from Django.
  • Python 3 : langage
  • Django : web framework for Python
  • Postgres : SQL database
  • Redis : cache
  • ElasticSearc : fast search engine
  • Wagtail : Django based headless CMS that provide a user friendly backend for pages edition
  • Boostrap : CSS framework
  • PyWikiBot : a python framework to communicate with Wikidata & Wikipedia APIs

Credits to packages or inspiration sources used for this project

Setup

Docker

See installation instructions at: docker documentation

Docker Compose

Install docker compose, see installation instructions at https://docs.docker.com/compose/install/

Environment variables

The file .env-sample contains the environment variables needed in the containers. It has to be renamed .env, wich is in the .gitignore file of the project.

Fire it up

Start the container by issuing one of the following commands:

$ docker-compose up             # run in foreground
$ docker-compose up -d          # run in background

Other commands

Restart in debug mode

$ sudo docker-compose down
$ sudo docker-compose build --no-cache
$ sudo docker-compose --verbose up --force-recreate 

Managing Django/Wagtail

$ sudo docker-compose exec app wagtail start project .  # not needed unless the current site structure is deleted
$ sudo docker-compose exec app pip install -r config/requirements.txt # not needed unless the current site structure is deleted
$ sudo docker-compose exec app ./manage.py makemigrations # has to be run after startup with migrate if the migration files have been deleted
$ sudo docker-compose exec app ./manage.py migrate # automated in the startup script with fake-initial
$ sudo docker-compose exec app ./manage.py collectstatic # automated in the startup script
$ sudo docker-compose exec app ./manage.py runserver 0.0.0.0:8000 
$ sudo docker-compose exec app ./manage.py createsuperuser

Then :

  • Get on mysite.com/admin and login
  • Add a new page with the homepage model.
  • Add a default site using this homepage as root.

Managing uWSGI

Reload uWSGI for the changes to take effect

$ docker-compose exec app touch /etc/uwsgi/reload-uwsgi.ini

Alias

This could help to speed up the process of typing commands... Edit bashrc to make this permanent :

vim ~/.bashrc #open the file with Vim text editor
:gg # go at the end of the file
# Hit i for interactive mode and copy-past above code. Then press escape.
:wq #save & quit
source ~/.bashrc #apply changes

Code to copy-past :

# Alias
alias e="sudo docker-compose exec"
alias ea="sudo docker-compose exec app"
alias m="sudo docker-compose exec app ./manage.py"
alias mmmig="sudo docker-compose exec app ./manage.py makemigrations"
alias mmig="sudo docker-compose exec app ./manage.py migrate"
alias mcol="sudo docker-compose exec app ./manage.py collectstatic"
alias mrun="sudo docker-compose exec app ./manage.py runserver 0.0.0.0:8000"
alias msup="sudo docker-compose exec app ./manage.py createsuperuser"
alias es="sudo docker-compose exec server"