如何使用自定义配置文件将ory/ file作为docker容器运行。是最好的运行方式还是提供环境变量更好。需要帮助!!
发布于 2020-11-03 01:24:04
我将dockerfile与以下内容一起使用:
FROM oryd/hydra:latest
COPY hydra.yml /home/ory/.hydra
COPY hydra.yml /.hydra
EXPOSE 4444 4445 5555只需要一份副本,但我不知道是哪一份:)
您可以使用env运行。变量,但我更喜欢yaml,它更容易
发布于 2021-11-24 03:46:15
除了上面提到的解决方案外,您还可以尝试Docker Compose。就我个人而言,我更喜欢这样,因为我发现它很容易遵循和管理。
官方的5分钟教程也使用了Docker Compose,可以在这里找到:https://www.ory.sh/hydra/docs/5min-tutorial/
我在这里使用PostgreSQL作为数据库,但是您可以用任何其他受支持的数据库(如MySQL )替换它。
此处提供了有关支持的数据库配置的更多信息:https://www.ory.sh/hydra/docs/dependencies-environment/#database-configuration
首先,创建如下所示的docker-compose.yml,然后只需创建docker-compose up
version: '3.7'
networks:
intranet:
driver: bridge
services:
hydra-migrate:
depends_on:
- auth-db
container_name: hydra-migrate
image: oryd/hydra:v1.10.6
environment:
- DSN=postgres://auth:secret@auth-db:5432/auth?sslmode=disable&max_conns=20&max_idle_conns=4
command: migrate sql -e --yes
networks:
- intranet
hydra:
container_name: hydra
image: oryd/hydra:v1.10.6
depends_on:
- auth-db
- hydra-migrate
ports:
- "4444:4444" # Public port
- "4445:4445" # Admin port
- "5555:5555" # Port for hydra token user
command:
serve -c /etc/hydra/config/hydra.yml all --dangerous-force-http
restart: on-failure
networks:
- intranet
volumes:
- type: bind
source: ./config
target: /etc/hydra/config
auth-db:
image: postgres:alpine
container_name: auth-db
ports:
- "5432:5432"
environment:
- POSTGRES_USER=auth
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=auth
networks:
- intranethydra-migrate服务负责数据库迁移,我们实际上不需要为此指定外部配置文件,只需将DSN作为环境变量就足够了。
hydra服务启动hydra容器,在这里我完成了一个卷挂载,将本地config文件夹绑定到容器内的/etc/hydra/config。
然后,当容器启动时,将执行以下命令serve -c /etc/hydra/config/hydra.yml all --dangerous-force-http,该命令使用绑定的配置文件。
下面是我的hydra配置文件的样子:
## ORY Hydra Configuration
version: v1.10.6
serve:
public:
cors:
enabled: true
dsn: postgres://auth:secret@auth-db:5432/auth?sslmode=disable&max_conns=20&max_idle_conns=4
oidc:
subject_identifiers:
supported_types:
- public
- pairwise
pairwise:
salt: youReallyNeedToChangeThis
urls:
login: http://localhost:4455/auth/login
consent: http://localhost:4455/auth/consent
logout: http://localhost:4455/consent
error: http://localhost:4455/error
post_logout_redirect: http://localhost:3000/
self:
public: http://localhost:4444/
issuer: http://localhost:4444/
ttl:
access_token: 1h
refresh_token: 1h
id_token: 1h
auth_code: 1h
oauth2:
expose_internal_errors: true
secrets:
cookie:
- youReallyNeedToChangeThis
system:
- youReallyNeedToChangeThis
log:
leak_sensitive_values: true
format: json
level: debughttps://stackoverflow.com/questions/64387913
复制相似问题