Yesod的DB可以配置环境变量吗? [英] Can Yesod's DB be configured with environment variables?

查看:170
本文介绍了Yesod的DB可以配置环境变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我搭建一个新的Yesod项目并选择例如PostgreSQL作为数据库,我得到了具有连接参数的 config / postgresql.yml 。但我想在一个Docker容器中运行我的数据库,并在另一个容器中运行该应用程序,并通过包含数据库IP,端口和内容的环境变量将这些数据库链接起来。



我告诉Yesod通过使用一堆环境变量进行配置来连接数据库? 是的,你可以通过以下环境变量:

 PGHOST
PGPORT
PGUSER
PGPASS
PGDATABASE


When I scaffold a new Yesod project and select e.g. PostgreSQL as the database, I get config/postgresql.yml that has the connection parameters. But I want to run my DB in one Docker container and the app in another, and link these via environment variables that contain the DB IP, port and whatnot.

How can I tell Yesod to connect to a database by using a bunch of environment variables for configuration?

解决方案

Yes, you can do this via the following environment variables:

    "PGHOST"
    "PGPORT"
    "PGUSER"
    "PGPASS"
    "PGDATABASE"

这篇关于Yesod的DB可以配置环境变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆