Hey team, I'm wondering how to best define environ...
# ask-community
a
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
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
@Vinnie and you have those values set in a .env file?
v
They’re environment variables fetched by the container on startup.
a
Where do you store the variables though>
v
They’re in my container definition
z
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
Yeah maybe not the right place to ask. I'll check the docker docs, thanks @Zach
🎉 1