redhat-buildpacks / testing

Project aiming to help us to perform e2e tests using Buildpacks
Apache License 2.0
0 stars 3 forks source link

Provide an example and dockerfile to build a nodejs app using extension and UBI #20

Closed cmoulliard closed 1 year ago

cmoulliard commented 1 year ago

TODO

In order to extend the upstream testing coverage, can you please take care about the following todos please :

Questions:

@mhdawson

mhdawson commented 1 year ago

@cmoulliard can you add some context to this? There are already instructions on how to build/use what we have so far in the upstream work here - https://github.com/paketo-community/ubi-nodejs-extension

That will change as the PRs related to the ubi stack land but it will likely remain the best place for instructions on how to use what we have in place so far.

I'm not quite sure what this is for: Design a Dockerfile able to install during the build phase the needed nodejs RPMs. The extension generates a docker file which is applied by the builder so no separate docker file should be needed.

This existing example can be built and run although it would be missing the back end database - https://github.com/nodeshift-starters/nodejs-rest-http

@cmoulliard maybe it makes sense for the two of us to get together so that I can share what all is in flight and better understrand what you need from our team.

cmoulliard commented 1 year ago

can you add some context to this? There are already instructions on how to build/use what we have so far in the upstream work here - https://github.com/paketo-community/ubi-nodejs-extension

For sure. The reason why I developed this project and recently added github actions is to b able to validate upstream our runtimes using: pack, tekton, quarkus client, shipwright and to be sure that our builders + some test cases will work. This is the purpose of this ticket

cmoulliard commented 1 year ago

I'm not quite sure what this is for: Design a Dockerfile able to install during the build phase the needed nodejs RPMs. The extension generates a docker file which is applied by the builder so no separate docker file should be needed.

Ok. So I will remove this request from the ticket description as N/A ;-)

cmoulliard commented 1 year ago

@cmoulliard maybe it makes sense for the two of us to get together so that I can share what all is in flight and better understrand what you need from our team.

Yes

cmoulliard commented 1 year ago

See project documenting how to use nodejs with UBI image: https://github.com/paketo-community/ubi-nodejs-extension

cmoulliard commented 1 year ago

Error reported by the job https://github.com/redhat-buildpacks/testing/actions/runs/5378308526/jobs/9757934836?pr=21

===> EXTENDING
Running the 'extender' on OS 'linux' with:
Container Settings:
  Args: '/cnb/lifecycle/extender -app /workspace -log-level debug'
  System Envs: 'CNB_EXPERIMENTAL_MODE=warn CNB_PLATFORM_API=0.12'
  Image: 'pack.local/builder/636a636e7274686c7574:latest'
  User: 'root'
  Labels: 'map[author:pack]'
Host Settings:
  Binds: 'pack-cache-library_test-app_latest-c58426545694.build:/kaniko pack-layers-xgwsrwffem:/layers pack-app-hbkwqaymys:/workspace'
  Network Mode: 'host'
[extender] Extending base image for build: container-registry.local:5000/quarkus-pack-hello@sha256:277dbc51909926d92573d50f6f49401dee21901afb709413c834fbffda70aad4
[extender] Starting build
[extender] Running build for buildpack paketo-buildpacks/ca-certificates@3.6.0
[extender] Looking up buildpack
[extender] Finding plan
[extender] Creating plan directory
[extender] Preparing paths
[extender] Running build command
[extender] 
[extender] Paketo Buildpack for CA Certificates 3.6.0
[extender]   https://github.com/paketo-buildpacks/ca-certificates
[extender]   Launch Helper: Contributing to layer
[extender]     Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
[extender] Processing layers
[extender] Updating environment
[extender] Reading output files
[extender] Updating buildpack processes
[extender] Updating process list
[extender] Finished running build for buildpack paketo-buildpacks/ca-certificates@3.6.0
[extender] Running build for buildpack paketo-buildpacks/node-engine@1.3.0
[extender] Looking up buildpack
[extender] Finding plan
[extender] Creating plan directory
[extender] Preparing paths
[extender] Running build command
[extender] Paketo Buildpack for Node Engine 1.3.0
[extender]   Resolving Node Engine version
[extender]     Candidate version sources (in priority order):
[extender]       package.json -> "18 || 16"
[extender]       <unknown>    -> ""
[extender] 
[extender] failed to satisfy "node" dependency version constraint "18 || 16": no compatible versions on "ubi8-paketo" stack. Supported versions are: []
[extender] ERROR: failed to build: exit status 1
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 51

Can you help me ? @mhdawson

mhdawson commented 1 year ago

@cmoulliard it looks like you don't have the extension as part of the builder. We have seen that error when the builder has not been build correctly to include the extension.

Looking at the output in what you posted I see:

Creating builder with the following buildpacks:
-> 'paketo-buildpacks/nodejs@1.4.0'
-> 'paketo-buildpacks/ca-certificates@3.6.0'
-> 'paketo-buildpacks/datadog@3.6.0'
-> 'paketo-buildpacks/environment-variables@4.5.0'
-> 'paketo-buildpacks/image-labels@4.4.1'
-> 'paketo-buildpacks/node-engine@1.3.0'
-> 'paketo-buildpacks/node-run-script@1.0.3'
-> 'paketo-buildpacks/node-start@1.0.4'
-> 'paketo-buildpacks/npm-install@1.0.4'
-> 'paketo-buildpacks/npm-start@1.0.4'
-> 'paketo-buildpacks/procfile@5.6.0'
-> 'paketo-buildpacks/watchexec@2.8.0'
-> 'paketo-buildpacks/yarn@1.1.3'
-> 'paketo-buildpacks/yarn-install@1.0.4'
-> 'paketo-buildpacks/yarn-start@1.0.4'

I don't see the extension there, but it is possible that it does not report extensions.

What does your builder.toml look like?

cmoulliard commented 1 year ago

What does your builder.toml look like?

See: https://github.com/redhat-buildpacks/testing/blob/5650a2c010b7ed44d2459989b738e55a1976ddf0/.github/nodejs_ubi_builder.toml

mhdawson commented 1 year ago

I would try the extra step in https://github.com/paketo-community/ubi-nodejs-extension/pull/6/files

cmoulliard commented 1 year ago

I would try the extra step in https://github.com/paketo-community/ubi-nodejs-extension/pull/6/files

You mean -> building the extension by executing the bash script build.sh ? @mhdawson

cmoulliard commented 1 year ago

You mean -> building the extension by executing the bash script build.sh ? @mhdawson

I updated the github action to include the build step

cmoulliard commented 1 year ago

Job is failing during export step: https://github.com/redhat-buildpacks/testing/actions/runs/5379904652/jobs/9761804922?pr=21#step:5:880

In order to verify if the procss is working end to end, I also executed it locally and got also an error locally which is a bit different

===> EXPORTING
Running the exporter on OS linux with:
Container Settings:
  Args: /cnb/lifecycle/exporter -daemon -launch-cache /launch-cache -log-level debug -app /workspace -cache-dir /cache -stack /layers/stack.toml test-app
  System Envs: CNB_USER_ID=1000 CNB_GROUP_ID=1000 CNB_PLATFORM_API=0.10
  Image: buildpacksio/lifecycle:0.17.0-pre.2
  User: root
  Labels: map[author:pack]
Host Settings:
  Binds: pack-cache-library_test-app_latest-c58426545694.build:/cache /var/run/docker.sock:/var/run/docker.sock pack-cache-library_test-app_latest-c58426545694.launch:/launch-cache pack-layers-acfprmxfpx:/layers pack-app-dwbnxjsgty:/workspace
  Network Mode: host
[exporter] ERROR: failed to export: get run image top layer SHA: image "test-app" has no layers
ERROR: failed to build: executing lifecycle. This may be the result of using an untrusted builder: failed with status code: 62
[5:38](https://redhat-internal.slack.com/archives/C04T5P4FVN2/p1687793921704069)

IMPORTANT: The local value of CNB_PLATFORM_API is 0.10 vs 0.12 when the job is executed by github !

See gist: https://gist.github.com/cmoulliard/c5cafc8d52934c6a42f84532e7dbc981#file-gistfile1-txt-L1

mhdawson commented 1 year ago

The current error looks like the run images have not been pulled by pack. There was a bug in pack that we'd worked with the cncf team to get fixed. Looks like I missed updating the instruction in terms of the minimum version of pack that is needed.

mhdawson commented 1 year ago

Created PR to fix that - https://github.com/paketo-community/ubi-nodejs-extension/pull/7