使用S2I制作了镜像,但是在s2i build 的时候出现如图报错
文档来源
我是按照KubeSphere v2.0 使用手册 用户指南->工作负载->自定义s2i模板 中的 步骤制作的,正常make build 之后产生镜像,但是在s2i build没有产生文档中的结果
我是按照KubeSphere v2.0 使用手册 用户指南->工作负载->自定义s2i模板 中的 步骤制作的,正常make build 之后产生镜像,但是在s2i build没有产生文档中的结果
发了几个问题可能是过于基础了吧,希望大神可以出手帮助。
jiasha
是不是没用 KubeSphere提供的基础镜像?贴下 dockerfile
shaowenchen ### 是的,没有使用基础镜像,因为比较看不懂s2i是怎么工作的。
# java-alpine-font
FROM taojintianxia/alpine-jdk8-maven
RUN apk add --update font-adobe-100dpi ttf-dejavu fontconfig
USER 1001
EXPOSE 8080
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
#!/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.
exec echo "----------------->>>>>> run!!!!!!!!"
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
文档里面其实有描述,如果使用的非 KubeSphere 提供的镜像可以参考 S2Irun 仓库下的一个文档,设置一些必要的 label ,提示也给出了。
原理就是,S2I 会先探测仓库的语言和框架,然后根据内置的脚本进行打包编译。如果你需要大量打包应用,也会需要维护这样一套模式,只不过 S2I 提供了一个社区的规范。可以参考 https://www.chenshaowen.com/blog/using-s2i-to-build-cloud-native-applications.html
要是平台上有自定义模板的操作界面和相应的功能就会好点吧。
shaowenchen 谢谢指导 : ) ,我看看先
shaowenchen 是的,经常修改倒也谈不上,但就是恰好使用的构建工具跟构建时需要的环境,平台没有提供,或者说我没发现,流水线定制是可以实现的,目前也是使用流水线先构建,然后再手动的添加构建环境,再去流水线发服务,感觉上是比较麻烦,如果能够通过S2I来一次性做好构建环境,这样就能方便点。
不,我是说用 DevOps 流水线交付这个功能,跑一下流水线就增加了一个 S2I 模板,而不是 UI。用 S2I 能免 Dockerfile 和 Yaml 编写,有其存在的空间。
shaowenchen 想了下是可以的,能够把生成的构建环境在下面的界面上方便的选择,这样会友好一些。