DjangoCMS on Aldryn/Docker

Collaboration through Aldryn

As Aldryn doesn’t have Github support, there are no PRs either. Collaboration is limited to:

Continuously export SASS/SCSS to CSS:

docker-compose run --rm web gulp watch --debug

Upload Changes to Aldryn Git

git pull
git add .
git commit -m "commit message"
git push

Apply changes from Aldryn Git

aldryn project update

or (quicker, if there are no changes to Aldryn settings):

git pull

Any migrations to apply?

docker-compose run --rm web python manage.py migrate

bring the project up again

aldryn project up

or

docker-compose up

Some Docker / Aldryn Tricks

Performance

Are you on Mac OS X? First of all, open the VirtualBox UI and release the docker machine from its pitiful state: Increase memory to 3GB and give it a second CPU (no need for additional GPU power though).

Troubleshooting

Whenever Aldryn complains that the docker-machine could not be found the solution is

eval $(docker-machine env default)

Shortcuts

add this to your ~/.profile

# execute manage.py in the docker container
docker_manage() {
 eval $(docker-machine env default)
 docker-compose run --rm web python manage.py "$@"
}
alias dmanage.py=docker_manage

# set env vars for the default docker machine (needed by all other docker / aldryn commands)
docker_env() {
 eval $(docker-machine env default)
}
alias denv=docker_env

# watch the aldryn-boilerplate-bootstrap3 sass into css
docker_watch() {
 eval $(docker-machine env default)
 docker-compose run --rm web gulp watch --debug
}
alias dwatch=docker_watch

# compile the aldryn-boilerplate-bootstrap3 sass into css
docker_build() {
 eval $(docker-machine env default)
 docker-compose run --rm web gulp build --debug
}
alias dbuild=docker_build

Some useful commands:

Rebuild the web container after adding a Django App:

docker-compose build web

Clean up old containers in batch:

docker ps -a | awk 'NR > 3 {print $1}' | xargs docker rm

Run docker containers on the command line (including log on the command line):

docker-compose up

Debug Aldryn Settings

docker-compose run --rm -e ALDRYN_ADDONS_DEBUG=True web python manage.py

This will give you a folder in

addons/.debug/

with the history of how settings are set by different Aldryn modules.

Create & install an Aldryn Addon on the local Aldryn setup

Here is the walkthrough: http://aldryn.readthedocs.org/en/master/tutorial/commandline/working-on-backend.html

DjangoCMS plugins & Django Apps with Aldryn

Understanding DjangoCMS Apps: http://www.django-cms.org/en/blog/2016/04/11/how-to-build-a-website-and-blog-with-django-cms-without-knowing-python-django-pt-8/

Understanding DjangoCMS apps in Aldryn: http://stackoverflow.com/questions/36664808/aldryn-how-to-add-own-django-apps-and-its-dependencies/36674127#36674127

How a messed up database situation can be recovered in Aldryn on OS X

When a django app migration did not work out the way it should have (for reasons that are beyond my understanding), I started to look into how to access the postgres database.

  1. Add this to your docker-compose.yml. This makes postgresql available on the docker machine’s IP address.
 ports:
  - "5432:5432"

Then reload the containers

docker-compose restart

And use pgAdmin or similar to connect. Find your docker machine’s ip like this:

docker-machine ip