Files
pulumi-docker-build/examples/tests/caching/index.ts
Bryce Lampe f0aaf7095d Fix GitHub action URL (#80)
Our docs and default value for the GitHub action cache URL were
referring to the
[wrong](https://github.com/tonistiigi/go-actions-cache/blob/master/api.md)
environment variable.

I was under the impression that the underlying library ends up checking
for the correct variable later so this would be only cosmetic, but a
user
[confirmed](https://github.com/pulumi/pulumi-docker-build/issues/77#issuecomment-2135621983)
this does appear to break things.

I brought over an old test I had written while this was still in the
pulumi-docker repo, but unfortunately it doesn't currently test GHA due
to ci-mgmt limitations
https://github.com/pulumi/pulumi-docker-build/issues/82.

Fixes https://github.com/pulumi/pulumi-docker-build/issues/77.
2024-05-29 12:29:58 +00:00

41 lines
1.1 KiB
TypeScript

import * as buildx from "@pulumi/docker-build";
import * as pulumi from "@pulumi/pulumi";
const config = new pulumi.Config();
const start = new Date().getTime();
// docker buildx build \
// -f Dockerfile \
// --cache-to type=local,dest=tmp,mode=max,oci-mediatypes=true \
// --cache-from type=local,src=tmp \
// --build-arg SLEEP-MS=$SLEEP_MS \
// -t not-pushed \
// -f Dockerfile \
// .
const img = new buildx.Image(`buildx-${config.require("name")}`, {
tags: ["not-pushed"],
dockerfile: { location: "Dockerfile" },
push: false,
context: { location: "." },
buildArgs: {
SLEEP_SECONDS: config.require("SLEEP_SECONDS"),
},
cacheTo: [{ raw: config.require("cacheTo") }],
cacheFrom: [{ raw: config.require("cacheFrom") }],
// Set registry auth if it was provided.
registries: config.require("username")
? [
{
address: config.getSecret("address"),
username: config.getSecret("username"),
password: config.getSecret("password"),
},
]
: undefined,
});
export const durationSeconds = img.ref.apply(
(_) => (new Date().getTime() - start) / 1000.0
);