搜索

3.4. 在 OpenShift 上部署第三方应用程序

download PDF

您可以使用编译的 WAR 文件或 EAR 归档为 OpenShift 部署创建应用程序镜像。使用 Dockerfile 将这些存档部署到 JBoss EAP 服务器上,以及包括操作系统、Java 和 JBoss EAP 组件的更新和全面的运行时堆栈。

注意

红帽不提供预构建的 JBoss EAP 服务器镜像。

3.4.1. 使用默认配置置备 JBoss EAP 服务器

您可以使用构建器镜像在 OpenShift 上安装和配置 JBoss EAP 服务器。对于无缝部署,请按照流程置备服务器、传输应用程序文件,并进行必要的自定义。

先决条件

  • 您可以访问受支持的 Red Hat JBoss Enterprise Application Platform 容器镜像。例如:

    • registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8
    • registry.redhat.io/jboss-eap-8/eap8-openjdk17-runtime-openshift-rhel8
  • 在您的系统上已安装了 podman。使用受支持的 RHEL 上可用的最新 podman 版本。如需更多信息,请参阅 Red Hat JBoss Enterprise Application Platform 8.0 支持的配置

流程

  1. 复制提供的以下 Dockerfile 内容:

    # Use EAP 8 Builder image to create a JBoss EAP 8 server
    # with its default configuration
    
    FROM registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8:latest AS builder
    
    # Set up environment variables for provisioning. 1
    ENV GALLEON_PROVISION_FEATURE_PACKS org.jboss.eap:wildfly-ee-galleon-pack,org.jboss.eap.cloud:eap-cloud-galleon-pack
    ENV GALLEON_PROVISION_LAYERS cloud-default-config
    # Specify the JBoss EAP version  2
    ENV GALLEON_PROVISION_CHANNELS org.jboss.eap.channels:eap-8.0
    
    
    # Run the assemble script to provision the server.
    RUN /usr/local/s2i/assemble
    
    # Copy the JBoss EAP 8 server from the builder image to the runtime image.
    FROM registry.redhat.io/jboss-eap-8/eap8-openjdk17-runtime-openshift-rhel8:latest AS runtime
    
    # Set appropriate ownership and permissions.
    COPY --from=builder --chown=jboss:root $JBOSS_HOME $JBOSS_HOME
    
    # Steps to add:
    # (1) COPY the WAR/EAR to $JBOSS_HOME/standalone/deployments
    #       with the jboss:root user. For example:
    #     COPY --chown=jboss:root my-app.war $JBOSS_HOME/standalone/deployments 3
    # (2) (optional) server modification. You can modify EAP server configuration:
    #
    #       * invoke management operations. For example
    #
    #        RUN $JBOSS_HOME/bin/jboss-cli.sh --commands="embed-server,/system-property=Foo:add(value=Bar)"
    #
    #        First operation must always be embed-server.
    #
    #       * copy a modified standalone.xml in $JBOSS_HOME/standalone/configuration/
    #          for example
    #
    #      COPY --chown=jboss:root standalone.xml  $JBOSS_HOME/standalone/configuration
    
    # Ensure appropriate permissions for the copied files.
    RUN chmod -R ug+rwX $JBOSS_HOME
    1
    您可以指定 MAVEN_MIRROR_URL 环境变量,这些变量供镜像内部的 JBoss EAP Maven 插件使用。如需更多信息,请参阅 Artifact repository mirrors
    2
    您不需要为任何次发行版本更新此 Dockerfile。如果要使用特定版本,请在 GALLEON_PROVISION_CHANNELS 环境变量中指定 JBoss EAP 版本。如需更多信息,请参阅 环境变量
    3
    修改复制的 Dockerfile,将 WAR 文件包含在容器中。例如:
    COPY --chown=jboss:root <my-app.war> $JBOSS_HOME/standalone/deployments

    将 <myapp.war> 替换为您要添加到镜像的 Web 存档的路径。

  2. 使用 podman 构建应用程序镜像:

    $ podman build -t my-app .

    执行该命令后,my-app 容器镜像已准备好在 OpenShift 上部署。

  3. 将容器镜像上传到以下选项之一:

  4. 从 registry 部署镜像时,请使用 Helm chart、Operator 或 Deployment 等部署策略。选择您首选的方法,并根据要求使用完整镜像 URL 或 ImageStreams。如需更多信息,请参阅使用 Helm chart 在 OpenShift 中构建和部署 JBoss EAP 应用程序
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.