#Pushing image with multiple tags using Node SDK

1 messages · Page 1 of 1 (latest)

chilly yarrow
#

I am trying to publish docker image with latest and current version tag. Calling publish multiple time works but the pipeline also runs multiple time. I can can see that the application is being built two times.

Is there a way to publish image with multiple tags without executing the whole pipeline again ?

async function pipeline(client: Client) {
  // Create base image that has pnpm
  const base = () => {
    return client.container().from('node:18.15.0-alpine').withExec(['corepack', 'enable'])
  }
  
  //...

  // Create the final image that runs the application
  const image = base()
    .withExec(['apk', 'add', 'ffmpeg', 'yt-dlp'])
    .withWorkdir('/app')
    .withDirectory('node_modules', production.directory('node_modules'))
    .withDirectory('dist', build.directory('dist'))
    .withFile('package.json', build.file('package.json'))
    .withExposedPort(3000)
    .withEntrypoint(['node', 'dist/index.js'])

  // Publish the image to registry
  const password = client.setSecret('docker-hub-password', REGISTRY_PASSWORD)
  const authed = image.withRegistryAuth(REGISTRY_URL, REGISTRY_USERNAME, password)

  await authed.publish(`${REGISTRY_USERNAME}/botto:latest`)
  await authed.publish(`${REGISTRY_USERNAME}/botto:${info.version}`)
}

// Run the pipeline
await connect(pipeline, { LogOutput: process.stdout })
harsh stone
#

Is the second build faster (cached)?

chilly yarrow
#

Yes installing dependencies and build for 2nd time are fast.

final dirge
#

I do this by pushing twice, all the steps are already cached so it doesn't actually build the app second times, and it runs super fast

harsh stone
#

Just to make sure, when I talked about the 2nd build, I was actually referring to the 2nd publish.