Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
leonitousconforti committed Oct 22, 2024
1 parent b43287c commit f886290
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
30 changes: 15 additions & 15 deletions scratchpad/playground.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
import * as NodeSocket from "@effect/platform-node/NodeSocket";
import * as Console from "effect/Console";
import * as Effect from "effect/Effect";
import * as Function from "effect/Function";
import * as Layer from "effect/Layer";

import * as Connection from "the-moby-effect/Connection";
import * as DockerEngine from "the-moby-effect/engines/Docker";
import { NodeContext, NodeRuntime } from "@effect/platform-node";
import { Console, Effect, Function, Layer } from "effect";
import { Engines, MobyConnection } from "the-moby-effect";

const layer = Function.pipe(
Connection.connectionOptionsFromPlatformSystemSocketDefault(),
Effect.map(DockerEngine.layerNodeJS),
Layer.unwrapEffect
MobyConnection.connectionOptionsFromPlatformSystemSocketDefault,
Effect.map((connectionOptionsToHost) =>
Engines.DindEngine.layerNodeJS({
connectionOptionsToHost,
exposeDindContainerBy: "socket" as const,
dindBaseImage: "docker.io/library/docker:25-dind-rootless" as const,
})
),
Layer.unwrapEffect,
Layer.provideMerge(NodeContext.layer)
);

Effect.gen(function* () {
yield* Console.log(void 0);
const data = yield* Engines.DockerEngine.version();
yield* Console.log(data);
})
.pipe(Effect.scoped)
.pipe(Effect.provide(layer))
.pipe(Effect.provide(NodeSocket.layerWebSocketConstructor))
.pipe(NodeRuntime.runMain);
10 changes: 9 additions & 1 deletion src/engines/Dind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,15 @@ const makeDindBinds = <ExposeDindBy extends Platforms.MobyConnectionOptions["_ta

const tempSocketDirectory = yield* Effect.if(exposeDindBy === "socket", {
onFalse: () => Effect.succeed(""),
onTrue: () => Effect.flatMap(FileSystem.FileSystem, (fs) => fs.makeTempDirectoryScoped()),
onTrue: () =>
Effect.flatMap(FileSystem.FileSystem, (fs) =>
Effect.gen(function* () {
const tempDirectory = yield* fs.makeTempDirectoryScoped();
yield* fs.chown(tempDirectory, 1000, 1000);
yield* fs.chmod(tempDirectory, 0o777);
return tempDirectory;
})
),
});

const boundDockerSocket = yield* Effect.if(exposeDindBy === "socket", {
Expand Down

0 comments on commit f886290

Please sign in to comment.