Skip to content

Conversation

@AndreasHeine
Copy link
Contributor

@AndreasHeine AndreasHeine commented Sep 28, 2023

hey,

i will tackle the auth topic in the next weeks!

i started working around it by using just dockerode:

 const requiredImages: string[] = [] for (const [_, value] of Object.entries(getServiceInstance().recipe.services)) { requiredImages.push((value as any).image) } await Promise.all(requiredImages.map(async (image: string) => { try { console.log("pulling image:", image) if (image.startsWith("localhost:15004/")) { const options = { // authconfig: { // username: config.regestryUser, // password: config.registryPw, // } } await pullImage(image, options) } else { await pullImage(image) } } catch (error: any) { console.error(image, "-->", error) } }))

but this has some flavour ;)

just passing the auth options like in this PR will probably not be enough because not all images of a service are exclusively from one Registry...

so for beeing able to use it in a common way we probably need to pass a array of auth options to the compose pull function so we can try to figure out from which registry we need to pull with the correct auth options.

#28

@AndreasHeine
Copy link
Contributor Author

small update on the subject:

i tested the following with two private registries!

export async function pullImage(image: string, options?: any): Promise<void> { if (options === undefined) { if (image.includes("myregistry1.com")) { options = { authconfig: { username: "myregistry1-user", password: "myregistry1-pw", auth: '', email: 'email@emailprovider.com', serveraddress: 'https://myregistry1.com/v2/' } } } if ( image.includes("myregistry2.com")) { options = { authconfig: { username: "myregistry2-user", password: "myregistry2-pw", auth: '', email: 'email@emailprovider.com', serveraddress: 'https://myregistry2.com/v2/' } } } } const pullStream = await docker.pull(image, options) await new Promise(res => docker.modem.followProgress(pullStream, res)) }

what that means in order to make a compose pull to a mix of registrys:

const registry = { "myregistry1.com": { username: "", password: "", email: "", serveraddress: "" }, "myregistry2.com": { username: "", password: "", email: "", serveraddress: "" }, } compose.pull(serviceN, options, registry) /*  inside compose.pull() we look if a prefix fits (myregistry1.com or myregistry2.com) and select to correct auth options  maybe like: Object.keys(registry).map((key) => {  if (imageName.includes(key)) {  return registry[key]  } }) */

PR update follows soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant