Open mhdawson opened 3 years ago
Is what you want the scenario where we would extend https://github.com/redhat-buildpacks/nodejs-buildpack so that we can add to the base image in https://github.com/redhat-buildpacks/nodejs-buildpack/blob/main/buildpacks/nodejs/buildpack.toml to add Node.js versus having bundled in?
Yes. We need for each runtime a testing
project where :
ubi8
one and not anymore ubi8-{nodejs,openjdk,...}
What we would want to test is:
That seems very good. I propose that we create a document using this test case and maybe generalize it to let the other runtimes to figure out what they should provide
Remark: It will also be needed to include some additional bits as needed by the RFC173 but we can extend the scenario as soon as we have a full picture about what to test ;-)
@mhdawson
@cmoulliard your suggestions sound reasonable to me.
@mhdawson FYI: I was able to create a simple POC which supports the concept to apply a Dockerfile. It uses a go buildah lib which can create an image from a Dockerfiles, next extract the layer(s) content. The code used is equivalent to the buildah bud command.
https://github.com/redhat-buildpacks/poc/blob/main/k8s/manifest.yml#L72-L135
Remark: As it is needed to modify the path to access the layer(s) content extracted within a volume (e.g. /layers --> export PATH="/layers/usr/bin:$PATH", ...), then the RFC perhaps should include an additional ARG or ENV VAR (CNB_EXTENSION_LAYERS) to let to specify where the layers will be extracted in order to change the $PATH during the build step.
I ran successfully a test case covering your nodejs request with our Kaniko POC able to process a Dockerfile https://github.com/redhat-buildpacks/poc/blob/35eed85b36ed7f31004a1dbcf5e13ac37dde4867/kaniko/workspace/ubi8-nodejs
FROM registry.access.redhat.com/ubi8
LABEL "runtime"="node_v14"
RUN yum -y module enable nodejs:14 && \
MODULE_DEPS="make gcc gcc-c++ libatomic_ops git openssl-devel" && \
INSTALL_PKGS="$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper" && \
ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && \
ln -s /usr/libexec/platform-python /usr/bin/python3 && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
yum -y clean all --enablerepo='*'
git clone https://github.com/redhat-buildpacks/poc.git && cd poc/kaniko
docker build -t kaniko-app -f Dockerfile_build .
dockerfile="ubi8-nodejs"
filesToSearch="node,hello.txt"
docker run \
-e EXTRACT_LAYERS=true \
-e IGNORE_PATHS="/proc" \
-e FILES_TO_SEARCH=${filesToSearch} \
-e LOGGING_LEVEL=info \
-e LOGGING_FORMAT=color \
-e DOCKER_FILE_NAME=${dockerfile} \
-v $(pwd)/workspace:/workspace \
-v $(pwd)/cache:/cache \
-it kaniko-app:latest
INFO[0000] The layered tzg files will be extracted to the home dir ...
INFO[0000] Starting the Kaniko application to process a Dockerfile ...
INFO[0000] Initialize the BuildPackConfig and set the defaults values ...
INFO[0000] Kaniko dir: /kaniko
INFO[0000] Workspace dir: /workspace
INFO[0000] Cache dir: /cache
INFO[0000] Dockerfile name: ubi8-nodejs
INFO[0000] Extract layer files ? true
INFO[0000] Building the ubi8-nodejs
INFO[0000] Retrieving image manifest registry.access.redhat.com/ubi8
INFO[0000] Retrieving image registry.access.redhat.com/ubi8 from registry registry.access.redhat.com
INFO[0001] Built cross stage deps: map[]
INFO[0001] Retrieving image manifest registry.access.redhat.com/ubi8
INFO[0001] Returning cached image manifest
INFO[0001] Executing 0 build triggers
INFO[0001] Unpacking rootfs as cmd RUN yum -y module enable nodejs:14 && MODULE_DEPS="make gcc gcc-c++ libatomic_ops git openssl-devel" && INSTALL_PKGS="$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper" && ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && ln -s /usr/libexec/platform-python /usr/bin/python3 && yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && rpm -V $INSTALL_PKGS && yum -y clean all --enablerepo='*' requires it.
-->
DEBU[0349] File found: /usr/bin/node
DEBU[0349] File found: /workspace/hello.txt
@mhdawson @matejvasek @lance @BarDweller @quintesse
Do you know why I got such an error when I build such a nodejs Dockerfile
docker run \
-e LOGGING_LEVEL=info \
-e IGNORE_PATHS="/var/spool/mail,/var/mail" \
-e EXTRACT_LAYERS=true \
-e FILES_TO_SEARCH=$TO_SEARCH \
-e METADATA_FILE_NAME=$FILE \
-v $(pwd)/../workspace:/workspace \
-v $(pwd)/cache:/cache \
-it kaniko-app
time="2022-01-21T16:36:55Z" level=info msg="Starting Kaniko application to process Dockerfile(s) ..."
time="2022-01-21T16:36:55Z" level=info msg="Initialize the BuildPackConfig and set the defaults values ..."
time="2022-01-21T16:36:55Z" level=info msg="The layered tzg files will be extracted to the home dir ..."
time="2022-01-21T16:36:55Z" level=info msg="Kaniko dir: /kaniko"
time="2022-01-21T16:36:55Z" level=info msg="Workspace dir: /workspace"
time="2022-01-21T16:36:55Z" level=info msg="Cache dir: /cache"
time="2022-01-21T16:36:55Z" level=info msg="Dockerfile name: Dockerfile"
time="2022-01-21T16:36:55Z" level=info msg="Extract layer files ? true"
time="2022-01-21T16:36:55Z" level=info msg="Metadata toml file: metadata_nodejs.toml"
time="2022-01-21T16:36:55Z" level=info msg="Parsing the Metadata toml file to decode it ..."
time="2022-01-21T16:36:55Z" level=info msg="Dockerfile path: /workspace/layers/nodejs/Dockerfile"
time="2022-01-21T16:36:55Z" level=info msg="Build arg: version=14"
time="2022-01-21T16:36:55Z" level=info msg="Build arg: runtime=nodejs"
time="2022-01-21T16:36:55Z" level=info msg="Building the /workspace/layers/nodejs/Dockerfile"
-->
time="2022-01-21T16:37:35Z" level=info msg="RUN yum -y module enable ${runtime}:${version} && MODULE_DEPS=\"make gcc gcc-c++ libatomic_ops git openssl-devel\" && INSTALL_PKGS=\"$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper\" && ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && ln -s /usr/libexec/platform-python /usr/bin/python3 && yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && rpm -V $INSTALL_PKGS && yum -y clean all --enablerepo='*'"
time="2022-01-21T16:37:35Z" level=info msg="cmd: /bin/sh"
time="2022-01-21T16:37:35Z" level=info msg="args: [-c yum -y module enable ${runtime}:${version} && MODULE_DEPS=\"make gcc gcc-c++ libatomic_ops git openssl-devel\" && INSTALL_PKGS=\"$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper\" && ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && ln -s /usr/libexec/platform-python /usr/bin/python3 && yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && rpm -V $INSTALL_PKGS && yum -y clean all --enablerepo='*']"
time="2022-01-21T16:37:35Z" level=info msg="Running: [/bin/sh -c yum -y module enable ${runtime}:${version} && MODULE_DEPS=\"make gcc gcc-c++ libatomic_ops git openssl-devel\" && INSTALL_PKGS=\"$MODULE_DEPS nodejs npm nodejs-nodemon nss_wrapper\" && ln -s /usr/lib/node_modules/nodemon/bin/nodemon.js /usr/bin/nodemon && ln -s /usr/libexec/platform-python /usr/bin/python3 && yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && rpm -V $INSTALL_PKGS && yum -y clean all --enablerepo='*']"
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Red Hat Universal Base Image 8 (RPMs) - BaseOS 849 kB/s | 796 kB 00:00
Red Hat Universal Base Image 8 (RPMs) - AppStream 1.8 MB/s | 2.6 MB 00:01
Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder 83 kB/s | 16 kB 00:00
Error: Problems in request:
missing groups or modules: nodejs:
panic: error building stage: failed to execute command: waiting for process to exit: exit status 1
goroutine 1 [running]:
github.com/redhat-buildpacks/poc/kaniko/buildpackconfig.(*BuildPackConfig).ProcessDockerfile(0xc00012c300, 0xc00061c0f0, 0x23)
/go/src/kaniko-app/buildpackconfig/buildPackConfig.go:138 +0xd05
main.main()
/go/src/kaniko-app/main.go:154 +0x1858
@mhdawson
Error: Problems in request: missing groups or modules: nodejs:
Fixed. My code was only taking one build argument and not 2 ;-) @mhdawson
@cmoulliard thanks for the heads up.
If I understand correctly this demonstrates that the PoC can build the dockerfile that we need. Is there a way to try that out under the buildpack infra yet? If so what would the steps be to do that?
Is there a way to try that out under the buildpack infra yet?
Which infra are you referring ?
If so what would the steps be to do that?
You can try the POC using instructions here - https://github.com/redhat-buildpacks/poc/tree/main/kaniko. It do not yet use Lifecycle but at least can validate what the output to execute a Dockerfile generates. The lifecycle should use it as reported by Nathalie here but I haven't yet make a test
Is what you want the scenario where we would extend https://github.com/redhat-buildpacks/nodejs-buildpack so that we can add to the base image in https://github.com/redhat-buildpacks/nodejs-buildpack/blob/main/buildpacks/nodejs/buildpack.toml to add Node.js versus having bundled in?
What we would want to test is:
1) start with the ubi8 (https://catalog.redhat.com/software/containers/ubi8/5c647760bed8bd28d0e38f9f) container instead of the ubi8-nodejs14 container shown in https://github.com/redhat-buildpacks/nodejs-buildpack/blob/main/builders/builder.toml.template 2) As part of the pre-step run
3) Build the content as per that buildpack 4) Use the minimal image when building the run image: https://catalog.redhat.com/software/containers/ubi8/ubi-minimal/5c359a62bed8bd75a2c3fba8 instead of the ubi:nodejs-14-minimal image and run this
@cmoulliard Can you help translate this outline to what is needed with the updated buildpack feature?