Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import labels from Dockerfile #7175

Open
djsnoopy opened this issue Mar 19, 2019 · 16 comments
Open

Import labels from Dockerfile #7175

djsnoopy opened this issue Mar 19, 2019 · 16 comments
Assignees
Labels
kind/requirement New feature or idea on top of harbor

Comments

@djsnoopy
Copy link

djsnoopy commented Mar 19, 2019

As requested from Wang Yan i´ll file the feature request to import labels from Dockerfile.

You already seem to import the maintainer label. It would be nice if the labels column would show the labels which exists in the Dockerfile. So users can search for images based on labels or use the labels as additional meta information for the image.

I. ex.:
I just created an image which contains centos, openJDK, hybris and a JDBC driver.
I added labels with specific informations about the versions of each element.
LABEL os="${OSVERSION}"
LABEL jdk="${JDKVERSION}"
LABEL hybris="${HYBRIS_PACKAGE}"
LABEL jdbc="${JDBC_DRIVER}"

Any discussions are highly appreciated

requirement

  1. if any user adds labels in their image, when you import that image into Harbor, import and attach the labels to that image as well. So labels from Docker are exposed as labels in Harbor
  2. [out of scope] Go back to existing images that were imported in Harbor and discover their labels (we can do this in a future release if users ask for it)
@wy65701436 wy65701436 self-assigned this Mar 19, 2019
@reasonerjt reasonerjt added the kind/requirement New feature or idea on top of harbor label Mar 21, 2019
@michmike michmike added this to 1.9 Proposals in Harbor Project Board Apr 24, 2019
@michmike michmike moved this from 1.9 Proposals to In progress in Harbor Project Board Apr 24, 2019
@michmike michmike moved this from In progress to 1.9 Proposals in Harbor Project Board Apr 24, 2019
@michmike michmike moved this from 1.9 Proposals to 1.9 Committment in Harbor Project Board May 20, 2019
@michmike michmike moved this from 1.9 Committment Proposal to 1.10 Proposals in Harbor Project Board Jun 11, 2019
@xaleeks
Copy link
Contributor

xaleeks commented Jul 29, 2019

Since Harbor labels currently are not k:v pairs, will this introduce a new k:v structure to Harbor, and if so should be this new structure be intact called 'labels' and the current harbor 'labels' need to vacate this title and find some other name. Or are we translating Dockerfiles labels into harbor labels so that the k:v information would need to be condensed into a single string

@xaleeks
Copy link
Contributor

xaleeks commented Jul 29, 2019

  1. [out of scope] Go back to existing images that were imported in Harbor and discover their labels (we can do this in a future release if users ask for it)
    Just double checking, this is referring to backfilling the images on harbor instances right now coming from docker but without previously imported labels?

@JordanSussman
Copy link

JordanSussman commented Aug 12, 2019

I envision this functionality enabling additional workflows that aren't currently possible with Harbor. For example:

Replication based on docker label

This functionality could start the work to greatly simplify the replication process workflow that I'm considering implementing. Today, the filters for replication are somewhat limiting, and instead I'd prefer to utilize metadata that we are already adding as labels to our build process to determine if the image should be replicated. A very brief example of how I envision this workflow looking:

FROM alpine:latest
LABEL replication=china

Resource filter: docker label
Pattern: replication=china

Result: replication to china harbor instance

Tag retention based on docker label

The tag retention policies capability could be expanded to include checks for images containing or lacking specific docker labels.

Enhanced search

Our current build process adds labels to track author, pull request (true or false), git org/repo, build server, etc. It would be helpful to query harbor to tell me how many images included the specific author or originated from a specific build server.

@wy65701436 wy65701436 assigned xaleeks and unassigned wy65701436 Aug 21, 2019
@webmutation
Copy link

interest in this i have

@xaleeks xaleeks moved this from 1.11 Proposals to Backlog in Harbor Project Board Dec 12, 2019
@vzanlnx
Copy link

vzanlnx commented Mar 4, 2020

I Also have interest in this feature. Would be very helpful to give more granularity in our pipeline process.

@sethbergman
Copy link

sethbergman commented Apr 26, 2020

I've been able to get this working in GitLab CI by using a for loop and iterating through the Dockerfile(s).

Simple version

variables: 
  DOCKERFILE: Dockerfile
  HARBOR_SERVER: harbor.example.com
  HARBOR_NAMESPACE: docker
script: |
  for DOCKERFILE in $DOCKERFILE
  do 
   DOCKER_IMAGE=$HARBOR_SERVER/$HARBOR_NAMESPACE/$CI_PROJECT_NAME:$CI_PIPELINE_ID
   LABELS="--label commit.sha=$CI_COMMIT_SHA --label project.url=$CI_PROJECT_URL 
   --label pipeline.url=$CI_PIPELINE_URL"
   docker build $LABELS --no-cache -t $DOCKER_IMAGE . -f $DOCKERFILE
   docker push $DOCKER_IMAGE
  done

@webmutation
Copy link

webmutation commented Apr 27, 2020

Hi @sethbergman I am not sure sure I understand how these tags are being passed to Harbor Labels... do you do an API call to Harbor somewhere after in the script?

Because that snippet only adds the labels to the build, afaik not what this issue is about. This issue is about getting the labels that are on the Docker image to be imported as Harbor labels... for this we can do an API calls to Harbor but it would be nicer if another more efficient mechanism was in place.

@senk
Copy link
Contributor

senk commented Apr 27, 2020

I guess you wanted to tag @sethbergman

@timchenxiaoyu
Copy link
Contributor

useful function

@Andreiaotto
Copy link

Hello, any plans to have this feature added?
Would be great as we are using labels for replication, teams are already used to have their labels in Dockerfile.

Thank you!

@tianon
Copy link
Member

tianon commented Apr 21, 2021

FWIW, the OCI decided to call these "image annotations" instead of "labels" which might help with differentiating them from Harbor's "labels": https://github.com/opencontainers/image-spec/blob/v1.0.1/annotations.md

@wy65701436 wy65701436 assigned qnetter and unassigned xaleeks Apr 14, 2022
@github-actions
Copy link

github-actions bot commented Jul 7, 2022

This issue is being marked stale due to a period of inactivity. If this issue is still relevant, please comment or remove the stale label. Otherwise, this issue will close in 30 days.

@github-actions github-actions bot added the Stale label Jul 7, 2022
@lindhe
Copy link

lindhe commented Jul 7, 2022

I think this should be kept open.

@github-actions github-actions bot removed the Stale label Jul 8, 2022
@Timmmm
Copy link

Timmmm commented Mar 10, 2023

How does this relate to the Annotations field which appears to be a K:V set, and the OCI spec linked there talks about author, description, etc.

If I set LABEL description=... in my Dockerfile should I expect it to show up in that column (pretty sure I've tried that and it doesn't unfortunately).

@VJGOPAL
Copy link

VJGOPAL commented Dec 7, 2023

Hi @sethbergman I am not sure sure I understand how these tags are being passed to Harbor Labels... do you do an API call to Harbor somewhere after in the script?

Because that snippet only adds the labels to the build, afaik not what this issue is about. This issue is about getting the labels that are on the Docker image to be imported as Harbor labels... for this we can do an API calls to Harbor but it would be nicer if another more efficient mechanism was in place.

could you please share how to authenticate the API calls to assign the label via workflow

@VJGOPAL
Copy link

VJGOPAL commented Dec 7, 2023

@webmutation, Please, could you share how to authenticate the API calls to assign the label via workflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/requirement New feature or idea on top of harbor
Projects
Development

No branches or pull requests