Search code examples
dockertestingkiwi-tcms

Common.py at Kiwi. How to mount to docker


I followed this Kiwi TCMS step, but what is really for me to is to understand how do you mount the common.py(main configuration file) to the working kiwi instance.

I don't see the place of common.py in the kiwi, so I dunno where to mount it? Or do I have to recreate the images every time to get the new settings?

EDIT: I've tried Kiwi TCMS configuration settings guide and I changed some settings in tcms/settings/common.py

How to implement that setting in the working Kiwi environment?


Solution

  • The config file approach

    The common.py file it seems to be located at tcms/settings/common.py as per your second link

    All sensible settings are defined in tcms/settings/common.py. You will have to update some of them for your particular production environment.

    If you really want to map only this file then from the root of your proeject:

    docker run -v ./tcms/settings/common.py:/absolute/container/path/to/tcms/settings/common.py [other-options-here] image-name
    

    Running the docker command with the above volume map will replace the file inside the docker container /absolute/container/path/to/tcms/settings/common.py with the one in the host tcms/settings/common.py, thus the application will run with the settings defined in the host.

    If you don't know the full path to tcms/settings/common.py inside the docker container, then you need to add the Dockerfile to your question so that we can help further.

    The ENV file approach

    If not already existing a .env file in the root of your project create one and add there all env variables in the common.py:

    .env example:

    KIWI_DB_NAME=my_db_name
    KIWI_DB_USER=my_db_user
    KIWI_DB_PASSWORD=my_db_password
    KIWI_DB_HOST=my_db_host
    KIWI_DB_PORT=my_db_port
    

    Add as many environment variables to the .env file as the ones you find in the python code that you want to customize.

    Start the docker container from the place where the .env file is with the flag --env-file .env, something like:

    docker run --env-file .env  [other-options-here] image-name