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

Adding fixes for ghcr.io #30

Merged
merged 5 commits into from
Jan 16, 2024
Merged

Adding fixes for ghcr.io #30

merged 5 commits into from
Jan 16, 2024

Conversation

eoftedal
Copy link
Owner

This seems helpful: https://distribution.github.io/distribution/spec/api/#digest-parameter

Had to change some of the content-types to reflect that (e.g. use application/octet-stream for non-manifest files). Seems to still work with the docker registry, but should be tested also with OpenShift or similar.

@eoftedal eoftedal requested a review from vehagn January 15, 2024 21:42
@eoftedal
Copy link
Owner Author

The github test case is in tests/githubtest/. Just set a GITHUB_TOKEN to a token from https://github.com/settings/tokens/new?scopes=write:packages and run test.sh

Copy link
Collaborator

@vehagn vehagn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

return resolve(headOk(res.headers.location, headers, allowInsecure, optimisticCheck, ++depth));
}
// Unauthorized
// Possibly related to https://gitlab.com/gitlab-org/gitlab/-/issues/23132
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can take a look at this. I managed to push to GitLab after getting a jwt token by running

SCOPE="repository:${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:pull,push"
AUTH_URL="${CI_SERVER_URL}/jwt/auth?service=container_registry&scope=${SCOPE}"
TOKEN=$(curl -sL --user "${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}" "${AUTH_URL}" | sed 's/.*"token":"\{0,1\}\([^,"]*\)"\{0,1\}.*/\1/')
yarn containerify --folder . --toRegistry "https://${CI_REGISTRY}/v2/${CI_PROJECT_NAMESPACE}" --toImage "${CI_PROJECT_NAME}:latest" --toToken $TOKEN

I assume we can run some checks on the container registry URL to determine if we should fetch this token or not.

@vehagn vehagn mentioned this pull request Jan 16, 2024
@eoftedal eoftedal merged commit 4833fe2 into master Jan 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants