https://dagster.io/ logo
#ask-community
Title
# ask-community
a

Alec Ryan

06/09/2022, 1:27 PM
Hey team, I'm wondering how to best define environment variables in my dagster YAML using a .env file ? For run storage, I'm doing something like this:
Copy code
run_storage:
  module: dagster_postgres.run_storage
  class: PostgresRunStorage
  config:
    postgres_db:
      username: ${DAGSTER_PG_USERNAME}"
      password: "${DAGSTER_PG_PASSWORD}"
      hostname: "${DAGSTER_PG_HOST}"
      db_name: ${DAGSTER_PG_DB}
      port: 5432
I've also tried this...
Copy code
run_storage:
  module: dagster_postgres.run_storage
  class: PostgresRunStorage
  config:
    postgres_db:
      username:
        env: "${DAGSTER_PG_USERNAME}"
      password:
        env: "${DAGSTER_PG_PASSWORD}"
      hostname:
        env: "${DAGSTER_PG_HOST}"
      db_name:
        env: "${DAGSTER_PG_DB}"
      port: 5432
I was stepping through the guide here: https://docs.dagster.io/deployment/guides/docker
dagster bot responded by community 2
v

Vinnie

06/09/2022, 1:39 PM
here’s mine that works, no need to set them as variables when you’re using the
env
property
Copy code
run_storage:
  module: dagster_postgres.run_storage
  class: PostgresRunStorage
  config:
    postgres_db:
      hostname:
        env: DAGSTER_POSTGRES_HOSTNAME
      username:
        env: DAGSTER_POSTGRES_USER
      password:
        env: DAGSTER_POSTGRES_PASSWORD
      db_name:
        env: DAGSTER_POSTGRES_DB
      port: 5432
a

Alec Ryan

06/09/2022, 2:28 PM
@Vinnie and you have those values set in a .env file?
v

Vinnie

06/09/2022, 2:29 PM
They’re environment variables fetched by the container on startup.
a

Alec Ryan

06/09/2022, 3:00 PM
Where do you store the variables though>
v

Vinnie

06/09/2022, 3:36 PM
They’re in my container definition
z

Zach

06/09/2022, 4:42 PM
this seems like it might be more of a docker thing than a dagster thing. if you're using docker compose you might want to look at this if you haven't seen it already - https://docs.docker.com/compose/env-file/
a

Alec Ryan

06/09/2022, 5:48 PM
Yeah maybe not the right place to ask. I'll check the docker docs, thanks @Zach
🎉 1