Skip to content

Commit 008d2ea

Browse files
committed
implementation of overlayfs root for podman
- unfortunately, this doesn't work on a network filesystem, so I will be deleting this entirely
1 parent ad488b5 commit 008d2ea

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/packages/project-runner/run/overlay.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import { replace_all } from "@cocalc/util/misc";
1010
const DEFAULT_IMAGE = "ubuntu:25.04";
1111

1212
const IMAGE_CACHE =
13-
process.env.COCALC_IMAGE_CACHE ?? join(data, "cache", "images");
14-
const PROJECT_ROOTS =
15-
process.env.COCALC_PROJECT_ROOTS ?? join(data, "cache", "project-roots");
13+
process.env.COCALC_OVERLAY_IMAGE_CACHE ?? join(data, "overlay", "images");
14+
const OVERLAY_ROOTFS =
15+
process.env.COCALC_OVERLAY_ROOTFS ?? join(data, "overlay", "rootfs");
16+
const OVERLAY_USER =
17+
process.env.COCALC_OVERLAY_USER ?? join(data, "overlay", "user");
1618

1719
export const extractBaseImage = reuseInFlight(async (image: string) => {
1820
const baseImagePath = join(IMAGE_CACHE, image);
@@ -82,11 +84,11 @@ export const extractBaseImage = reuseInFlight(async (image: string) => {
8284
});
8385

8486
function getMergedPath(project_id) {
85-
return join(PROJECT_ROOTS, project_id);
87+
return join(OVERLAY_ROOTFS, `project-${project_id}`);
8688
}
8789

88-
function getPaths({ home, image, project_id }) {
89-
const userOverlays = join(home, ".overlay", image);
90+
function getPaths({ image, project_id }) {
91+
const userOverlays = join(OVERLAY_USER, `project-${project_id}`, image);
9092
const upper = join(userOverlays, "upper");
9193
const workdir = join(userOverlays, "workdir");
9294
const merged = getMergedPath(project_id);
@@ -99,16 +101,14 @@ function getImage(config) {
99101

100102
export async function mount({
101103
project_id,
102-
home,
103104
config,
104105
}: {
105106
project_id: string;
106-
home: string;
107107
config?: Configuration;
108108
}) {
109109
const image = getImage(config);
110110
const lower = await extractBaseImage(image);
111-
const { upper, workdir, merged } = getPaths({ home, image, project_id });
111+
const { upper, workdir, merged } = getPaths({ image, project_id });
112112
await mkdir(upper, { recursive: true });
113113
await mkdir(workdir, { recursive: true });
114114
await mkdir(merged, { recursive: true });
@@ -147,7 +147,7 @@ async function mountOverlayFs({ upper, workdir, merged, lower }) {
147147
"overlay",
148148
"overlay",
149149
"-o",
150-
`lowerdir=${escape(lower)},upperdir=${escape(upper)},workdir=${escape(workdir)}`,
150+
`lowerdir=${escape(lower)},upperdir=${escape(upper)},workdir=${escape(workdir)},index=on,nfs_export=on,xino=auto,redirect_dir=on`,
151151
merged,
152152
],
153153
});

src/packages/project-runner/run/podman.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function start({
3939
}
4040

4141
const home = await mountHome(project_id);
42-
const rootfs = await rootFilesystem.mount({ project_id, home, config });
42+
const rootfs = await rootFilesystem.mount({ project_id, config });
4343
await mkdir(home, { recursive: true });
4444
await ensureConfFilesExists(home);
4545
const env = getEnvironment({

0 commit comments

Comments
 (0)