Search code examples
cookiecutter-django

Django Cookiecutter using environment variables pattern in production


I am trying to understand how to work with production .env files in a django cookie cutter generated project.

The documentation for this is here:

https://cookiecutter-django.readthedocs.io/en/latest/developing-locally-docker.html#configuring-the-environment

The project is generated and creates .local and .production folders for environment variables.

I am attempting to deploy to a docker droplet in digital ocean.

Is my understanding correct:

The .production folder is NEVER checked into source control and are only generated as examples of what to create on a production machine when I am ready to deploy?

So when I do deploy , as part of that process I need to do a pull/clone of the project on the docker droplet and then either

manually create the .production folder with the production environment variables folder structure?

OR

RUN merge_production_dotenvs_in_dotenv.py locally to create .env file that I copy onto production and the configure my production.yml to use that?

Thanks Chris


Solution

  • The production env files are NOT into source control, only the local ones are. At least that is the intend, production env files should not be in source control as they contain secrets.

    However, they are added to the docker image by docker-compose when you run it. You may create a Docker machine using the Digital Ocean driver, activate it from your terminal, and start the image you've built by running docker-compose -f production.yml -d up.