-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: specify expose port in dockerfile #5820
Conversation
When traefik is used, the host cannot be accessed to 8090 by default after being configured. Therefore, you need to configure loadbalance. The process is complicated, so specify the expose port
|
当前 halo:
image: halohub/halo:2.14
restart: on-failure:3
container_name: halo
depends_on:
postgres:
condition: service_healthy
volumes:
- halo:/root/.halo2
healthcheck:
test: ["CMD", "curl", "-f", "http://halo:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:postgresql://postgres/halo
- --spring.r2dbc.username=USER_NAME
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
- --spring.r2dbc.password=PASSWORD
- --spring.sql.init.platform=postgresql
# 外部访问地址,请根据实际需要修改
# - --halo.external-url=http://example.com
labels:
- "traefik.http.routers.halo.rule=Host(`example.com`)"
- "traefik.http.routers.halo.service=svc_halo"
- "traefik.http.services.svc_halo.loadbalancer.server.port=8090" 如果指定了 Expose 后, 可以变成: halo:
image: halohub/halo:2.14
restart: on-failure:3
container_name: halo
depends_on:
postgres:
condition: service_healthy
volumes:
- halo:/root/.halo2
healthcheck:
test: ["CMD", "curl", "-f", "http://halo:8090/actuator/health/readiness"]
interval: 30s
timeout: 5s
retries: 5
start_period: 30s
command:
- --spring.r2dbc.url=r2dbc:pool:postgresql://postgres/halo
- --spring.r2dbc.username=USER_NAME
# PostgreSQL 的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致。
- --spring.r2dbc.password=PASSWORD
- --spring.sql.init.platform=postgresql
# 外部访问地址,请根据实际需要修改
# - --halo.external-url=http://example.com
labels:
- "traefik.http.routers.halo.rule=Host(`example.com`)" 不用关心里面具体的端口是什么,可以更直接的启动 |
感谢 @croatialu,这看起来会很有用,但是我这里有一个问题:目前用户可以在外挂配置文件中或者参数中(--server.port)指定运行端口,我们需要考虑这种情况吗?或者如果这样配置了其他端口之后,是否会有什么副作用。 ping @halo-dev/sig-halo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JohnNiang, ruibaby The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
无影响,当手动指定其他端口后,端口映射上修改一下就行。 如果在使用traefik 情况下修改了内部的运行端口, 则需要配置traefik 的load balance,就像我上面所写的。 |
What type of PR is this?
/kind improvement
What this PR does / why we need it:
When traefik is used, the host cannot be accessed to 8090 by default after being configured. Therefore, you need to configure loadbalance. The process is complicated, so specify the expose port
当使用 traefik 时, 配置完 host 后无法直接的访问到对应的服务, 需要额外的配置service, loadbalance.port 才能, 所以建议增加一个 expose port, 指定下默认的服务端口
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?