Add the sha256 digest to the deployment image reference (#1673)

This commit is contained in:
Eric Allam
2025-02-06 19:14:34 +00:00
committed by GitHub
parent 3ec6983e45
commit f00ed9b13e
@@ -28,11 +28,14 @@ export class FinalizeDeploymentV2Service extends BaseService {
friendlyId: id,
environmentId: authenticatedEnv.id,
},
include: {
select: {
status: true,
id: true,
version: true,
externalBuildData: true,
environment: true,
worker: {
include: {
tasks: true,
select: {
project: true,
},
},
@@ -84,6 +87,14 @@ export class FinalizeDeploymentV2Service extends BaseService {
throw new ServiceValidationError("Missing depot token");
}
const digest = extractImageDigest(body.imageReference);
logger.debug("Pushing image to registry", {
id,
deployment,
digest,
});
const pushResult = await executePushToRegistry(
{
depot: {
@@ -110,10 +121,19 @@ export class FinalizeDeploymentV2Service extends BaseService {
throw new ServiceValidationError(pushResult.error);
}
const fullImage = digest ? `${pushResult.image}@${digest}` : pushResult.image;
logger.debug("Image pushed to registry", {
id,
deployment,
body,
fullImage,
});
const finalizeService = new FinalizeDeploymentService();
const finalizedDeployment = await finalizeService.call(authenticatedEnv, id, {
imageReference: pushResult.image,
imageReference: fullImage,
skipRegistryProxy: true,
});
@@ -121,6 +141,19 @@ export class FinalizeDeploymentV2Service extends BaseService {
}
}
// Extracts the sha256 digest from an image reference
// For example the image ref "registry.depot.dev/gn57tl6chn:8qfjm8w83w@sha256:aa6fd2bdcbbd611556747e72d0b57797f03aa9b39dc910befc83eea2b08a5b85"
// would return "sha256:aa6fd2bdcbbd611556747e72d0b57797f03aa9b39dc910befc83eea2b08a5b85"
function extractImageDigest(image: string) {
const digestIndex = image.lastIndexOf("@");
if (digestIndex === -1) {
return;
}
return image.substring(digestIndex + 1);
}
type ExecutePushToRegistryOptions = {
depot: {
buildId: string;