For developers

Sensitive environment variables

3min

For security reasons, it's important to keep sensitive data, like access keys or security tokens, outside the code repository. Hosty is no-UI hosting blueprint, therefore there's no interface to add sensitive environment variables. However, Hosty has a recommended approach to deal with sensitive data.

Hosty assumes that deployments are handled in CI tools , like CircleCI or similar. These tools have mechanism to add environment variables and store them on their side. Then, during a deployment job in CI, there must be a step to create a .env file (the name can be different, but it's important to stick to the dotenv-like file structure). The last step is to configure Hosty to load environment variables from it. Let's look it each step is a bit more detail.

Step 1: Add environment variables to your CI platform



Example screenshot taken from CircleCI
Example screenshot taken from CircleCI


Step 2: Add a step to add environment variables to a .env file

The name of the file with secrets can be any, as long as it follows dotenv file format.

.circleci/config.yml


Step 3: Tell Hosty.yaml to load environment variables from the file

For each application container, you can specify an optional parameter environmentFiles with the list of the dotenv-formatted files containing environment variables for the container. Here's an example for the php container:

hosty.yaml


Hosty will load environment variables from the file and make them available in the deployed container (in this particular example - php container).