cloud-native-toolkit / cloud-native-toolkit/planning

Carlos wants labels to be added to the container images in the starter kits

Open
#675 0 comments 0 reactions 0 assignees View on GitHub
code pattern feature good first issue Workstream:CI/CD and GitOps
Dominant language
No language data
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Common labels are defined by Open Containers - https://github.com/opencontainers/image-spec/blob/master/annotations.md#rules

We should at least set the following labels dynamically during the build process:
- org.opencontainers.image.created
- org.opencontainers.image.title
- org.opencontainers.image.source
- org.opencontainers.image.revision
- build-date
- name
- url
- vcs-ref

Other values would not be dynamic and we could provide them as examples in the Dockerfile. This would require the developer to update the values after the creating from the starter kit. They could also be included in the Dockerfile but commented out.
- org.opencontainers.image.description
- org.opencontainers.image.authors
- org.opencontainers.image.url
- org.opencontainers.image.documentation
- org.opencontainers.image.vendor
- org.opencontainers.image.licenses
- version
- release
- vendor

It means we will need to define ARGs in the Dockerfile as well and update the build step of the pipelines to pass them in. E.g.

```Dockerfile
ARG BUILD_DATE
ARG NAME
ARG VCS_URL
ARG VCS_REF

LABEL org.opencontainers.image.created=$BUILD_DATE \
build-date=$BUILD_DATE \
org.opencontainers.image.title=$NAME \
name=$NAME \
org.opencontainers.image.source=$VCS_URL \
url=$VCS_URL \
org.opencontainers.image.revision=$VCS_REF \
vcs-ref=$VCS_REF
```

In the pipeline task (https://github.com/IBM/ibm-garage-tekton-tasks/blob/main/tasks/2-build-tag-push.yaml):

```shell
buildah bud \
--build-arg BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--build-arg NAME=$IMAGE_NAME \
--build-arg VCS_URL=$GIT_URL \
--build-arg VCS_REF=$GIT_REF \
...
```

__Update:__

Some additional info from @bwoolf1 on existing labels from the UBI images:

```json
"Labels": {
"architecture": "x86_64",
"build-date": "2020-07-23T05:54:39.075680",
"com.redhat.build-host": "cpt-1004.osbs.prod.upshift.rdu2.redhat.com",
"com.redhat.component": "nodejs-12-container",
"com.redhat.deployments-dir": "/opt/app-root/src",
"com.redhat.dev-mode": "DEV_MODE:false",
"com.redhat.dev-mode.port": "DEBUG_PORT:5858",
"com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
"description": "Node.js 12 available as container is a base platform for building and running various Node.js 12 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.",
"distribution-scope": "public",
"help": "For more information visit https://github.com/sclorg/s2i-nodejs-container",
"io.k8s.description": "Node.js 12 available as container is a base platform for building and running various Node.js 12 applications and frameworks. Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.",
"io.k8s.display-name": "Node.js 12",
"io.openshift.expose-services": "8080:http",
"io.openshift.s2i.scripts-url": "image:///usr/libexec/s2i",
"io.openshift.tags": "builder,nodejs,nodejs12",
"io.s2i.scripts-url": "image:///usr/libexec/s2i",
"maintainer": "SoftwareCollections.org \u003csclorg@redhat.com\u003e",
"name": "ubi8/nodejs-12",
"release": "52",
"summary": "Platform for building and running Node.js 12 applications",
"url": "https://access.redhat.com/containers/#/registry.access.redhat.com/ubi8/nodejs-12/images/1-52",
"usage": "s2i build \u003cSOURCE-REPOSITORY\u003e ubi8/nodejs-12:latest \u003cAPP-NAME\u003e",
"vcs-ref": "a6b3970d86fb885d9c20445676a2f31aa9bedf0b",
"vcs-type": "git",
"vendor": "Red Hat, Inc.",
"version": "1"
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.