发了几个问题可能是过于基础了吧,希望大神可以出手帮助。

    shaowenchen ### 是的,没有使用基础镜像,因为比较看不懂s2i是怎么工作的。

    • dockerfile如下:
    # java-alpine-font
    FROM taojintianxia/alpine-jdk8-maven 
    RUN apk add --update font-adobe-100dpi ttf-dejavu fontconfig
    USER 1001
    EXPOSE 8080
    • MakeFile如下:
    IMAGE_NAME = kubespheredev/java-alpine-font
    
    .PHONY: build
    build:
    	docker build -t $(IMAGE_NAME) .
    
    .PHONY: test
    test:
    	docker build -t $(IMAGE_NAME)-candidate .
    	IMAGE_NAME=$(IMAGE_NAME)-candidate test/run
    • s2i/bin/assemble
    #!/bin/bash -e
    #
    # S2I assemble script for the 'java-alpine-font' image.
    # The 'assemble' script builds your application source so that it is ready to run.
    #
    # For more information refer to the documentation:
    #	https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
    #
    
    # If the 'java-alpine-font' assemble script is executed with the '-h' flag, print the usage.
    if [[ "$1" == "-h" ]]; then
    	exec /usr/libexec/s2i/usage
    fi
    
    # Restore artifacts from the previous build (if they exist).
    #
    if [ "$(ls /tmp/artifacts/ 2>/dev/null)" ]; then
      echo "---> Restoring build artifacts..."
      # mv /tmp/artifacts/. ./
    fi
    
    echo "---> Installing application source..."
    # cp -Rf /tmp/src/. ./
    
    echo "---> Building application from source..."
    # TODO: Add build steps for your application, eg npm install, bundle install, pip install, etc.
    • s2i/bin/run
    exec echo "----------------->>>>>> run!!!!!!!!" 

      shaowenchen

      s2i工程结构如下

      s2i-alpine-java-font/
      ├── Dockerfile
      ├── Makefile
      ├── README.md
      ├── s2i
      │   └── bin
      │       ├── assemble
      │       ├── run
      │       └── usage
      ├── s2ibuildertemplate.yml
      └── test
          ├── run
          └── test-app
              └── index.html
      
      4 directories, 9 files

      jiasha

      文档里面其实有描述,如果使用的非 KubeSphere 提供的镜像可以参考 S2Irun 仓库下的一个文档,设置一些必要的 label ,提示也给出了。

      原理就是,S2I 会先探测仓库的语言和框架,然后根据内置的脚本进行打包编译。如果你需要大量打包应用,也会需要维护这样一套模式,只不过 S2I 提供了一个社区的规范。可以参考 https://www.chenshaowen.com/blog/using-s2i-to-build-cloud-native-applications.html

        要是平台上有自定义模板的操作界面和相应的功能就会好点吧。

          jiasha

          通常用户不会去修改这个,主要是平台方才会关注。你那边需要经常修改么?

          如果提供一条 DevOps 流水线,填写基础镜像和参数就能用来定制 S2I ,是不是就能满足你的要求?

            shaowenchen 是的,经常修改倒也谈不上,但就是恰好使用的构建工具跟构建时需要的环境,平台没有提供,或者说我没发现,流水线定制是可以实现的,目前也是使用流水线先构建,然后再手动的添加构建环境,再去流水线发服务,感觉上是比较麻烦,如果能够通过S2I来一次性做好构建环境,这样就能方便点。

              jiasha

              不,我是说用 DevOps 流水线交付这个功能,跑一下流水线就增加了一个 S2I 模板,而不是 UI。用 S2I 能免 Dockerfile 和 Yaml 编写,有其存在的空间。

                shaowenchen 想了下是可以的,能够把生成的构建环境在下面的界面上方便的选择,这样会友好一些。