Skip to content

Commit

Permalink
make it possible to specify google cloud base image via remote url in…
Browse files Browse the repository at this point in the history
…stead of hardcoding it in the source code
  • Loading branch information
williamstein committed Dec 14, 2024
1 parent 16b800e commit 6c88f2c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
16 changes: 10 additions & 6 deletions src/packages/frontend/compute/select-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,16 @@ export function ImageLinks({ image, style }: { image; style? }) {
<A style={{ flex: 1 }} href={data.source}>
<Icon name="github" /> GitHub
</A>
<A style={{ flex: 1 }} href={data.url}>
<Icon name="external-link" /> {trunc(data.label, 10)}
</A>
<A style={{ flex: 1 }} href={packageNameToUrl(data.package)}>
<Icon name="docker" /> DockerHub
</A>
{!!data.url && (
<A style={{ flex: 1 }} href={data.url}>
<Icon name="external-link" /> {trunc(data.label, 10)}
</A>
)}
{!!data.package && (
<A style={{ flex: 1 }} href={packageNameToUrl(data.package)}>
<Icon name="docker" /> DockerHub
</A>
)}
</div>
);
}
Expand Down
39 changes: 22 additions & 17 deletions src/packages/server/compute/cloud/google-cloud/create-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,20 @@ function getConf({
}
}

/*
ubuntu-2404-noble-amd64-v20241004
ubuntu-2404-noble-arm64-v20241004
*/
function getSourceImage(arch: Architecture, IMAGES: Images) {
const version = IMAGES["google-cloud"]?.["base_image"]?.[arch];
if (version) {
return version;
}

// hard coded fallback:
// ubuntu-2404-noble-arm64-v20241115
// ubuntu-2404-noble-amd64-v20241115
const GOOGLE_CLOUD_UBUNTU_VERSION = "20241115";

function getSourceImage(arch: Architecture) {
return `projects/ubuntu-os-cloud/global/images/ubuntu-2404-noble-${
arch == "arm64" ? "arm" : "amd"
}64-v20241004`;
}64-v${GOOGLE_CLOUD_UBUNTU_VERSION}`;
}

const LOGDIR = "logs";
Expand Down Expand Up @@ -504,16 +509,16 @@ function createBuildConfiguration({
machineType: "n2-standard-8",
} as const)
: arch == "x86_64"
? ({
region: "us-east1",
zone: "us-east1-b",
machineType: "c2-standard-4",
} as const)
: ({
region: "us-central1",
zone: "us-central1-a",
machineType: "t2a-standard-4",
} as const)),
? ({
region: "us-east1",
zone: "us-east1-b",
machineType: "c2-standard-4",
} as const)
: ({
region: "us-central1",
zone: "us-central1-a",
machineType: "t2a-standard-4",
} as const)),
} as const;

// IMPORTANT SECURITY NOTE: Do *NOT* install microk8s, even for an image
Expand Down Expand Up @@ -558,6 +563,6 @@ sync
startupScript,
maxTimeMinutes,
arch,
sourceImage: getSourceImage(arch),
sourceImage: getSourceImage(arch, IMAGES),
} as const;
}
6 changes: 3 additions & 3 deletions src/packages/util/db-schema/compute-servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface Image {
// What we show the user to describe this image, e.g., in the image select menu.
label: string;
// The name of the package on npmjs or dockerhub:
package: string;
package?: string;
// In case there is a different package name for ARM64, the name of it.
package_arm64?: string;
// Root filesystem image must be at least this big in GB.
Expand All @@ -90,9 +90,9 @@ export interface Image {
dockerSizeGb?: number;
description?: string;
// Upstream URL for this image, e.g., https://julialang.org/ for the Julia image.
url: string;
url?: string;
// Icon to show next to the label for this image.
icon: string;
icon?: string;
// Link to a URL with the source for building this image.
source: string;
// optional list of links to videos about this image, ordered from lowest to highest priority.
Expand Down

0 comments on commit 6c88f2c

Please sign in to comment.