Use docker env file and setup config in entrypoint #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@avdata99 I have been reviewing this repo. This is PR to discuss a few points mostly regarding env variables and configuration files. I'm pointing it to my own fork to not mess around with your project.
Context
While normally Django/Flask have a straightforward approach
ENV Variables -> Run Application
, CKAN has an outdated*.ini
file in between, forcing us to doENV Variables -> .ini File -> Run CKAN
. In other words, Django/Flask usually run the application and then setup their configuration object, while CKAN has a strong dependency on having a.ini
file to be able to even execute the application (and then setup the configuration object).This is why we always need an extra step to dump the environment variables into a configuration file before even attempting to run CKAN. This is always mandatory, even extensions like
ckanext-envvars
do not work properly if we start from a badckan.ini
file (see ckan/ckanext-envvars#10)I think this typical workflow designed for CD/CI can be simplified by using a
production.ini
file to directly handle secrets but that's another story.Main change
The main change of this PR is to move all code related to ENV Variables to the entrypoint so we can use
docker run --env-file ...
or theenv_file
variable of docker compose.This has the benefit of bringing CKAN development closer to Django/Flask:
docker build ...
will take care mostly of copying files, installing dependencies and requirements.docker run ...
will take care of the configuration and running the application (plus local development stuff).This means that:
build-env-vars.sh
is no longer needed, this is taking care by Docker while running the applicationsetup-ckan-ini-file.sh
is moved to the entrypoint.Other small changes
patches
folder, so we can clean the one that it is not used.docker/ckan/setup
is not being used, so we can clean it.Let me know your thoughts, with all this changes, this is properly working on my machine TM 😂