dotenv-vscode icon indicating copy to clipboard operation
dotenv-vscode copied to clipboard

Feature Request: Cloak env variables in Docker definition .yaml files

Open akulmehta opened this issue 3 years ago • 5 comments

Very nice extension. It would be great if the extension could also cloak the environment variables in .yaml files.

akulmehta avatar Mar 08 '23 01:03 akulmehta

Interesting. @akulmehta, can you share an example .yaml file like that?

motdotla avatar Mar 22 '23 01:03 motdotla

Below is an example of the .yaml file:

runtime: php
env: flex
  document_root: public
skip_files:
  - .env
env_variables: # the values for fields under this heading would be sensitive information like the DB information
  APP_ENV: local
  APP_DEBUG : true
  DB_CONNECTION: mysql
  DB_HOST: localhost
  DB_DATABASE: instance_id
  DB_USERNAME: database_user_name
  DB_PASSWORD: database_password
beta_settings:
  setting1: project:cloud-instance

The nested fields are indicated by indentation and the environment variables are put under the heading of env_variables for this case, however it can be different for different applications/pipelines.

akulmehta avatar Mar 22 '23 13:03 akulmehta

What frameworks or languages use this .yaml approach? I'm just curious before we start work on this. Why not just use a .env file?

motdotla avatar Jun 15 '23 04:06 motdotla

@motdotla .yaml is used in Docker for containerized apps and serverless apps. Docker in turn is used by several frameworks and apps for deployment.

akulmehta avatar Jun 17 '23 16:06 akulmehta

I see. You're using environment variables inside a docker yaml definition file.

Optionally, you could reference a .env file from there instead. We recommend this because it is safer and also more flexible (you can now swap in different .env files and manage them from a secrets manager like dotenv-vault or others)

version: '3.8'
services:
  my-service:
    image: your-image
    env_file:
      - .env

BUT I acknowledge this is also a common and convenient way to define them. I've done it myself many times.

We'll consider this feature as others request it as well. It would be nice to have.

motdotla avatar Jun 17 '23 16:06 motdotla