Log in

Docker

schizoidDavid Curran
  • 16 Feb

I saw in the Road Map the idea of having a Docker image designed for quickly getting a test forum so figured I'd give it a go.

I've got an image created here https://hub.docker.com/r/schizoid90/spirit/

Got a bit of an issue with SECRET_KEY. Even thought it is defined in the various settings files, Django is still complaining that it doesn't exist

Code is here
https://bitbucket.org/schizoid90/spirit-docker/src

Anyone got any ideas on how to fix this?

Uwsgi is looking at the examples directory under Spirit.

schizoidDavid Curran
  • 17 Feb

Got this working, had to do some odd stuff with environment variables and pythonpath...

There is a working Docker image available from the link in my previous post.

It is based on Ubuntu:16.04
It can be better, at the moment the image size is 871.1MB when downloaded, which is a bit much considering what it's for. This is mostly down to the base Ubuntu image as well as the python modules that get installed.

docker run -dit -p 80:80 schizoid90/spirit
docker attach <container_name>
python /var/www/html/Spirit/example/manage.py spiritinstall
uwsgi --ini /etc/uwsgi/spirit.ini
Then navigate to your server on port 80

Unfortunately due to spiritinstall not supporting --noinput (which I see is a "TO DO") you need to run the command in the container so that you can accept the warning about "collect statistics" and then start uwsgi.

nitelyEsteban Castro Borsani
  • 17 Feb

This topic has been moved.

nitelyEsteban Castro Borsani
  • 6
  • 17 Feb

There is an open PR for this[0]. I didn't merge it coz there are a few things to work out regarding creating a project. I want to add a command that should create a project ala django-admin startproject but never got around it.

Got a bit of an issue with SECRET_KEY. Even thought it is defined in the various settings files, Django is still complaining that it doesn't exist

Yeah, that var is required when debug is turned off (i.e for a production deploy) and it has to be non-empty. django-admin startproject command will generate a key but if you use the example project, it does not have one.

One way to set that variable is using an environment variable. That's probably the most popular one coz it's very flexible, you can set it in many places (i.e wsgi.py, ansible book, apache/nginx config file, command line, etc). Even docker has a way to set them[1]. That's how the heroku app[2] works for many settings (secret_key, admin email, default language, etc).

There are other more secure ways? yes... Vault[3] for example. But I bet someone going that far will use its own docker file.

It can be better, at the moment the image size is 871.1MB when downloaded, which is a bit much considering what it's for. This is mostly down to the base Ubuntu image as well as the python modules that get installed.

Also coz every docker command (ie RUN, FROM, etc ) creates a new layer which increments the size considerably. There are ways to compress it, easiest one is chaining as many commands as possible. There are other more hackish ways I don't remember. Not sure if docker has a way to compress/remove layers now but there was an open issue for that last time I checked. The downside is if one command fails then you have to start from scratch instead of the last docker command, so trade-offs.

However, when pulling from the hub, the image is 325MB, no?

Unfortunately due to spiritinstall not supporting --noinput (which I see is a "TO DO") you need to run the command in the container so that you can accept the warning about "collect statistics" and then start uwsgi.

haha, actually that's the reason that "todo" is there, I had the same issue when using docker.

[0] https://github.com/nitely/Spirit/pull/106
[1] https://docs.docker.com/compose/environment-variables/
[2] https://github.com/nitely/spirit-heroku
[3] https://www.vaultproject.io

schizoidDavid Curran
  • 17 Feb

@nitely said:
There is an open PR for this[0]. I didn't merge it coz there are a few things to work out regarding creating a project. I want to add a command that should create a project ala django-admin startproject but never got around it.

Didn't see that, ahh well it's still a fun project :-)

Got a bit of an issue with SECRET_KEY. Even thought it is defined in the various settings files, Django is still complaining that it doesn't exist

Yeah, that var is required when debug is turned off (i.e for a production deploy) and it has to be non-empty. django-admin startproject command will generate a key but if you use the example project, it does not have one.

One way to set that variable is using an environment variable. That's probably the most popular one coz it's very flexible, you can set it in many places (i.e wsgi.py, ansible book, apache/nginx config file, command line, etc). Even docker has a way to set them[1]. That's how the heroku app[2] works for many settings (secret_key, admin email, default language, etc).

There are other more secure ways? yes... Vault[3] for example. But I bet someone going that far will use its own docker file.

Yeah I just added in an environment variable and that fixed it

It can be better, at the moment the image size is 871.1MB when downloaded, which is a bit much considering what it's for. This is mostly down to the base Ubuntu image as well as the python modules that get installed.

Also coz every docker command (ie RUN, FROM, etc ) creates a new layer which increments the size considerably. There are ways to compress it, easiest one is chaining as many commands as possible. There are other more hackish ways I don't remember. Not sure if docker has a way to compress/remove layers now but there was an open issue for that last time I checked. The downside is if one command fails then you have to start from scratch instead of the last docker command, so trade-offs.

However, when pulling from the hub, the image is 325MB, no?

That's the compressed size, just got this working and can make it more efficient later.

Unfortunately due to spiritinstall not supporting --noinput (which I see is a "TO DO") you need to run the command in the container so that you can accept the warning about "collect statistics" and then start uwsgi.

haha, actually that's the reason that "todo" is there, I had the same issue when using docker.

I did have a quick look at how to get round it but struggle

[0] https://github.com/nitely/Spirit/pull/106
[1] https://docs.docker.com/compose/environment-variables/
[2] https://github.com/nitely/spirit-heroku
[3] https://www.vaultproject.io

Reply