Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Compose development environment #238

Closed
wants to merge 1 commit into from

Conversation

martinblech
Copy link
Contributor

Vagrant support was dropped in favor of Docker based development environments, but no replacement was provided. This should do.

@martinblech martinblech force-pushed the master branch 2 times, most recently from 9d20306 to ff0c28a Compare May 18, 2015 23:47
@luzfcb
Copy link
Collaborator

luzfcb commented May 19, 2015

Hello @martinblech, that sounds good.

What will I speak, it is only my opinion, and can not be the same as the rest of the team.

First, I'm still trying to understand how the Docker ecosystem works.

having said that, I have some questions:

  1. All the structure of this project, assumes he is running on Ubuntu 14.04 Server/Desktop (Ok, it works almost unmodified on other Linux systems). This docker setting is based on what operating system?
  2. Some libraries from Python dependencies, have C extensions that need to be compiled at installation time. The compile dependencies to build these python libraries in Ubuntu 14.04 are listed on requirements.apt file. How this would work in Docker?
  3. If someone see this docker configuration and want to put in a production environment. From this configuration uses some images available on Docker Hub, to what extent I can trust in the security settings applied in these images (server hardening)? The Database password is auto-generated? The database is accessible outside the container?

I think some of the answers to these questions should be included in the documentation to avoid problems and wrong interpretations.
Every day that passes, I think that "Explicit is better than implicit" is really an incredible excellent idea.

@martinblech
Copy link
Contributor Author

Hello @luzfcb, thank you for your feedback.

  1. It's supposed to be OS-independent, but to be honest I have only tried it in OS X via boot2docker. I wouldn't expect there to be any problems, as Docker images are supposed to be completely isolated from the host OS. Do you have a Ubuntu or Windows box at reach where you could try it?
  2. All the dependencies build fine with pip install -r requirements/local.txt during the image build stage. It seems that the base python:3.4 image has all the compile dependencies.
  3. Dockerfile and docker-compose.yml are only intended for development purposes. Perhaps a comment there stating so is enough?

Couldn't agree more about "explicit is better than implicit".

Vagrant support was dropped in favor of Docker based development environments,
but no replacement was provided. This should do.
@martinblech
Copy link
Contributor Author

@luzfcb Please look at the comments I just amended to Dockerfile and docker-compose.yml.

@jayfk
Copy link
Collaborator

jayfk commented Jul 15, 2015

While having a development environment powered by compose is neat, I'd go one step further and add a configuration that works for dev and prod.

I'd suggest the following:

  • A configuration for production with four services: postgres, memcached, gunicorn and nginx as a reverse proxy. If celery support is enabled, add three more: rabbitmq, celery-worker and celery-beat.
  • A configuration for development with postgres and a django image that runs runserver_plus and mounts the code to the running container, so auto reloading etc. works.

As of compose 0.3.0 there's no good solution to inherit from a common configuration like cookiecutter-django does with common.py, so two files are needed.

  • A docker-compose.yml for production, so all is needed is to run docker-compose up -d on the prod server.
  • A dev.yml for development. There are two ways to run that:
    • Set the environment variable COMPOSE_FILE to dev.yml and run docker-compose up, or
    • Run docker-compose -f dev.yml up

In fact, I've ported a couple of projects that were started with cookiecutter-django to a working configuration with docker-compose.

If there's interest in that, I'd be happy to put something together over the next few days.

@martinblech
Copy link
Contributor Author

The extends keyword can be used for sharing common configurations between development and production .yml files. Here's an example from the Docker Compose docs: https://docs.docker.com/compose/extends/

@jayfk
Copy link
Collaborator

jayfk commented Jul 16, 2015

Yes, but it has some limitations that make it pretty unusable. What we really need is a concept like includefrom #318 or global_extends from #1380.

@jayfk
Copy link
Collaborator

jayfk commented Jul 21, 2015

I made a PR here #284

It is basically working like @martinblech's contribution for development with a few tweaks (env variables are set automatically in entrypoint.sh, for example) and a working configuration that can be used as a starting point to run it in production.

@pydanny
Copy link
Member

pydanny commented Aug 18, 2015

Closing as #284 encompasses this excellent work.

@pydanny pydanny closed this Aug 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants