简体   繁体   English

Quarkus Stylish 不能在容器镜像中工作(Openshift / Docker)

[英]Quarkus Stylish not working in container images (Openshift / Docker)

We are updating our documentation and adding branding for the generated pages.我们正在更新我们的文档并为生成的页面添加品牌。 We used the input described here ( https://quarkus.io/blog/stylish-api/ ).我们使用了此处描述的输入( https://quarkus.io/blog/stylish-api/ )。 However, for some reason, the styling works locally (when starting Quarkus in dev mode) but not running it in a container technology (we tried both OpenShift and Docker images. No css is applied, no logos are altered. Not for the landing page and not for generated swagger pages. Is there some setting / something we need to do additionally to get it working?但是,由于某种原因,样式在本地工作(在开发模式下启动 Quarkus 时)但不能在容器技术中运行(我们尝试了 OpenShift 和 Docker 图像。没有应用 css,没有更改徽标。不适用于登录页面而不是生成的 swagger 页面。是否有一些设置/我们需要额外做的事情才能让它工作?

The following properties are set in the application.properties在 application.properties 中设置了以下属性

quarkus.swagger-ui.title=Title
quarkus.swagger-ui.filter=true
quarkus.swagger-ui.enable=true
quarkus.swagger-ui.always-include=true

I suspect that none of the additional resources (in META-INF) are picked up by Quarkus when building a container image.我怀疑在构建容器映像时,Quarkus 没有获取任何其他资源(在 META-INF 中)。

Structure:结构:

\resources
  \META-INF
   application.properties
     beans.xml
     \branding
        logo.png
        style.css
     \resources
        favicon.ico
        index.html

We can see that the /swagger-ui/style.css is different.我们可以看到 /swagger-ui/style.css 是不同的。 Running in dev the build process copies style.css from the branding dir to the /swagger-ui.在 dev 中运行构建过程将 style.css 从品牌目录复制到 /swagger-ui。 This does (apparantly) not happen when building an image.这在构建图像时(显然)不会发生。

The /swagger-ui/ folder is placed under META_INF in the runner jar. /swagger-ui/ 文件夹位于运行器 jar 中的 META_INF 下。 It contains the wrong css (the original one).它包含错误的 css(原版)。 Running quarkus in dev mode apparantly does serve this folder from a different location (probably the branding location and replaces the original.在开发模式下运行 quarkus 显然会从不同的位置(可能是品牌位置并替换原始位置)提供此文件夹。

It's apparently somemthing in the maven build.这显然是 maven 版本中的东西。

By default, Swagger UI is only available when Quarkus is started in dev or test mode.默认情况下,Swagger UI 仅在 Quarkus 在开发或测试模式下启动时可用。

If you want to make it available in production too, you can include the following configuration in your application.properties:如果您也想让它在生产中可用,您可以在 application.properties 中包含以下配置:

quarkus.swagger-ui.always-include=true

https://quarkus.io/guides/openapi-swaggerui#use-swagger-ui-for-development https://quarkus.io/guides/openapi-swaggerui#use-swagger-ui-for-development

The quarkus-maven-plugin needs an additional goal (prepare) in order to include the css on the right location. quarkus-maven-plugin 需要一个额外的目标(准备)以便在正确的位置包含 css。

            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <version>${quarkus-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare</goal>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

After this the styling was applied.在此之后应用样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM