Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • castellum castellum
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CastellumCastellum
  • castellumcastellum
  • Merge requests
  • !64

Environment variables test

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Tyapkov requested to merge environment-variables-test into master Jun 13, 2018
  • Overview 7
  • Commits 3
  • Pipelines 1
  • Changes 10

In the previous setup we had different settings files in settings folder. These settings where later mounted into the docker container on docker-compose up.

Drawbacks of previous aproach:

  1. Settings specified in separate files are not secured. Users who can see settings files do also have access to all the "secured" variables.
  2. Mounting the volume is a bad idea, because we cannot collect static files or create folders in the mounting volume during the docker build.
  3. Tree structure does not allow to find required settings in a fast way, you have to switch between different settings files.
  4. During the mount of the settings file, empty files appeared in the git (example.py), which should be deleted after containers are off. Otherwise we have to create empty file in the repository.

How it works:

  1. In the root of the project we have env file in which all the production variables are saved. In my case ENV file looks like:
DEBUG=False
DB_NAME_DEFAULT=***
DB_USER_DEFAULT=***
DB_HOST_DEFAULT=***
DB_NAME_SUBJECT_MANAGEMENT=***
DB_USER_SUBJECT_MANAGEMENT=****
DB_HOST_SUBJECT_MANAGEMENT=***
ALLOWED_HOSTS=***
AUTH_LDAP_SERVER_URI=***
AUTH_LDAP_BIND_DN=***
AUTH_LDAP_BIND_PASSWORD=***
AUTH_LDAP_SCOPE=***
AUTH_LDAP_PARAM=***

where *** are actual settings

  1. We have 2 yml files used for docker-compose. One is used to run production environment, another for development environment. If you use PyCharm then you can create setup to run either development or production environment.
  2. Variables of docker-compose-dev.yml (DEBUG and etc) override variables defined in ENV file and enables development settings.
  3. It is still possible to use local development environment without docker. When you run python manage.py runserver default variables from settings.py are in use.
Edited Jun 13, 2018 by Tyapkov
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: environment-variables-test