Skip to content
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

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

croatialu
Copy link
Contributor

@croatialu croatialu commented Apr 28, 2024

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?

None

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
@CLAassistant
Copy link

CLAassistant commented Apr 28, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Apr 28, 2024
@f2c-ci-robot f2c-ci-robot bot requested review from guqing and LIlGG April 28, 2024 03:41
@croatialu
Copy link
Contributor Author

当前 Traefik 的配置如下

  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`)"

不用关心里面具体的端口是什么,可以更直接的启动

@ruibaby
Copy link
Member

ruibaby commented Apr 29, 2024

感谢 @croatialu,这看起来会很有用,但是我这里有一个问题:目前用户可以在外挂配置文件中或者参数中(--server.port)指定运行端口,我们需要考虑这种情况吗?或者如果这样配置了其他端口之后,是否会有什么副作用。

ping @halo-dev/sig-halo

Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经过手动测试,不会对当前的安装流程造成任何影响。

https://docs.docker.com/reference/dockerfile/#expose

/approve

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 29, 2024
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Apr 29, 2024
Copy link

f2c-ci-robot bot commented Apr 29, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 29, 2024
@f2c-ci-robot f2c-ci-robot bot merged commit 2bcab94 into halo-dev:main Apr 29, 2024
8 checks passed
@croatialu
Copy link
Contributor Author

感谢 @croatialu,这看起来会很有用,但是我这里有一个问题:目前用户可以在外挂配置文件中或者参数中(--server.port)指定运行端口,我们需要考虑这种情况吗?或者如果这样配置了其他端口之后,是否会有什么副作用。

ping @halo-dev/sig-halo

无影响,当手动指定其他端口后,端口映射上修改一下就行。

如果在使用traefik 情况下修改了内部的运行端口, 则需要配置traefik 的load balance,就像我上面所写的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants