Skip to content

Commit

Permalink
Switch to undock to download image
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupuis committed Dec 19, 2023
1 parent 657b2d1 commit e06e4ce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ CO*.md
build/test/
build/typedoc/

test/event.*
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ RUN apk add --no-cache \
skopeo \
&& skopeo --version

# container-diff
RUN curl -sLO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 \
&& chmod +x container-diff-linux-amd64 \
&& mv container-diff-linux-amd64 /usr/bin/container-diff \
&& container-diff version
# undock
COPY --from=crazymax/undock:0.7.0-rc.1 /usr/local/bin/undock /usr/local/bin/undock

WORKDIR "/skill"

Expand Down
26 changes: 8 additions & 18 deletions lib/events/register_skill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,28 +288,18 @@ async function downloadImage(
log.info("Downloading image");
const tmpDir = await tmpFs.createDir(ctx);
const imageNameWithDigest = fullImageName(ctx.data.image);
const args = ["analyze", "--type=file", imageNameWithDigest];
const env = { ...process.env, CONTAINER_DIFF_CACHEDIR: tmpDir };
const result = await childProcess.spawnPromise(
"container-diff",
args,
{
env,
},
);
const args = [
imageNameWithDigest,
tmpDir,
"--include=skill.yaml",
"--include=datalog",
];
const result = await childProcess.spawnPromise("undock", args);
if (result.status !== 0) {
throw new Error("Failed to download layers");
}
log.info(`Successfully downloaded image`);
return [
path.join(
tmpDir,
".container-diff",
"cache",
imageNameWithDigest.replace(/\//g, "").replace(/:/g, "_"),
),
registry,
] as any;
return [tmpDir, registry] as any;
},
);
}
Expand Down

0 comments on commit e06e4ce

Please sign in to comment.