Skip to content

Commit 43a4948

Browse files
committed
Local stack shares coursier/ivy cache with devcontainers
1 parent 1df6399 commit 43a4948

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

e2e-tests/images/datastore.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ WORKDIR /workflow-backend
3636
# Install JVM tooling (java, sbt) via mise using the e2e environment. This is the
3737
# only thing baked into the image; all backend sources are bind-mounted at runtime.
3838
COPY .tool-versions ./
39-
RUN mise trust -a && mise install java sbt
39+
RUN --mount=type=cache,target=/mise/cache,sharing=locked \
40+
mise trust -a && mise install java sbt
4041

4142
EXPOSE 9095
4243

e2e-tests/images/workflow-frontend.Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ WORKDIR /workflow-frontend
3636
# so `yarn` is available. This is the only thing baked into the image; the repo
3737
# and its node_modules are bind-mounted at runtime.
3838
COPY .tool-versions ./
39-
RUN mise trust -a && mise install java nodejs sbt aws-cli \
39+
RUN --mount=type=cache,target=/mise/cache,sharing=locked \
40+
mise trust -a && mise install java nodejs sbt aws-cli \
4041
&& mise exec nodejs -- npm install -g corepack \
4142
&& mise exec nodejs -- corepack enable
4243

e2e-tests/setup/stack/containers.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,24 @@ function getBackendDir(e2eRoot: string): string {
262262
);
263263
}
264264

265+
// Bind-mount the devcontainer's persistent coursier/ivy cache volumes (see
266+
// .devcontainer/*/devcontainer.json) into sbt containers as their dependency
267+
// caches, so `sbt update`/`run` reuse artifacts already fetched from Maven
268+
// Central across container/image rebuilds instead of re-downloading them.
269+
// Falls back to no extra mounts when run outside that devcontainer.
270+
function sbtCacheBindMounts(): { source: string; target: string; mode: "rw" }[] {
271+
const coursierCacheDir = process.env.DEVENV_COURSIER_CACHE_MOUNT_DIR;
272+
const ivyCacheDir = process.env.DEVENV_IVY_CACHE_MOUNT_DIR;
273+
const mounts: { source: string; target: string; mode: "rw" }[] = [];
274+
if (coursierCacheDir) {
275+
mounts.push({ source: coursierCacheDir, target: "/root/.cache/coursier", mode: "rw" });
276+
}
277+
if (ivyCacheDir) {
278+
mounts.push({ source: ivyCacheDir, target: "/root/.ivy2", mode: "rw" });
279+
}
280+
return mounts;
281+
}
282+
265283
function buildDatastoreImage(
266284
e2eRoot: string,
267285
imageTag: string,
@@ -300,6 +318,7 @@ export async function startDatastore(
300318
// baking it into the image. Read-write because sbt writes target/ dirs.
301319
.withBindMounts([
302320
{ source: backendDir, target: "/workflow-backend", mode: "rw" },
321+
...sbtCacheBindMounts(),
303322
])
304323
.withLogConsumer(createLogConsumer("datastore", streamLogs))
305324
.withExposedPorts(9095)
@@ -376,6 +395,7 @@ export async function startWorkflow(
376395
// webpack write target/ and public/build into it.
377396
.withBindMounts([
378397
{ source: repoRoot, target: "/workflow-frontend", mode: "rw" },
398+
...sbtCacheBindMounts(),
379399
])
380400
.withEnvironment({
381401
AWS_ENDPOINT_URL_S3: `http://${S3_ENDPOINT_HOST}:${LOCALSTACK_PORT}`,

0 commit comments

Comments
 (0)