-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
503fe2f
commit 4d28822
Showing
12 changed files
with
117 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,28 @@ | ||
#!/usr/bin/env node | ||
import { Args, Command, Options } from "@effect/cli"; | ||
import { NodeContext } from "@effect/platform-node"; | ||
import { Effect, Stream } from "effect"; | ||
import { DockerEngine, MobyConvey } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
import * as Effect from "effect/Effect"; | ||
import * as Function from "effect/Function"; | ||
import * as Layer from "effect/Layer"; | ||
import * as Stream from "effect/Stream"; | ||
|
||
import * as DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import * as MobyConvey from "the-moby-effect/MobyConvey"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make( | ||
export const command = Command.make( | ||
"build", | ||
{ | ||
tag: Cli.Options.text("tag"), | ||
dockerfile: Cli.Options.text("dockerfile").pipe(Cli.Options.withDefault("Dockerfile")), | ||
context: Cli.Args.directory({ exists: "yes" }), | ||
tag: Options.text("tag"), | ||
dockerfile: Options.text("dockerfile").pipe(Options.withDefault("Dockerfile")), | ||
context: Args.directory({ exists: "yes" }), | ||
}, | ||
({ context, dockerfile, tag }) => | ||
Effect.gen(function* () { | ||
const context2 = Stream.provideSomeLayer( | ||
const contextStream = Stream.provideSomeLayer( | ||
MobyConvey.packBuildContextIntoTarballStream(context, [dockerfile]), | ||
NodeContext.layer | ||
); | ||
|
||
const buildStream = DockerEngine.build({ | ||
tag, | ||
dockerfile, | ||
context: context2, | ||
context: contextStream, | ||
}); | ||
|
||
yield* MobyConvey.followProgressInConsole(buildStream); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "build", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Command } from "@effect/cli"; | ||
import { NodeContext, NodeRuntime } from "@effect/platform-node"; | ||
import { Effect, Function, Layer } from "effect"; | ||
import { DockerEngine, MobyConnection } from "the-moby-effect"; | ||
|
||
import { command as buildCommand } from "./build.js"; | ||
import { command as execCommand } from "./exec.js"; | ||
import { command as imagesCommand } from "./images.js"; | ||
import { command as infoCommand } from "./info.js"; | ||
import { command as psCommand } from "./ps.js"; | ||
import { command as pullCommand } from "./pull.js"; | ||
import { command as runCommand } from "./run.js"; | ||
import { command as searchCommand } from "./search.js"; | ||
import { command as stopCommand } from "./stop.js"; | ||
import { command as versionCommand } from "./version.js"; | ||
|
||
const command = Command.make("docker").pipe( | ||
Command.withSubcommands([ | ||
buildCommand, | ||
execCommand, | ||
imagesCommand, | ||
infoCommand, | ||
psCommand, | ||
pullCommand, | ||
runCommand, | ||
stopCommand, | ||
searchCommand, | ||
versionCommand, | ||
]) | ||
); | ||
|
||
const cli = Command.run(command, { | ||
name: "Docker CLI", | ||
version: "0.0.0", | ||
}); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const MainLive = Layer.merge(DockerLive, NodeContext.layer); | ||
|
||
cli(process.argv).pipe(Effect.provide(MainLive), NodeRuntime.runMain); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,15 @@ | ||
#!/usr/bin/env node | ||
import { Command, Options } from "@effect/cli"; | ||
import { Effect } from "effect"; | ||
import { DockerEngine } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
import * as Effect from "effect/Effect"; | ||
import * as Function from "effect/Function"; | ||
import * as Layer from "effect/Layer"; | ||
|
||
import * as DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make( | ||
export const command = Command.make( | ||
"exec", | ||
{ | ||
cmd: Cli.Options.text("cmd"), | ||
containerId: Cli.Options.text("container"), | ||
cmd: Options.text("cmd"), | ||
containerId: Options.text("container"), | ||
}, | ||
({ cmd, containerId }) => | ||
Effect.gen(function* () { | ||
yield* DockerEngine.exec({ containerId, command: cmd.split(" ") }); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "exec", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,10 @@ | ||
#!/usr/bin/env node | ||
import { Command } from "@effect/cli"; | ||
import { Console, Effect } from "effect"; | ||
import { DockerEngine } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
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 DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make("images", {}, () => | ||
export const command = Command.make("images", {}, () => | ||
Effect.gen(function* () { | ||
const data = yield* DockerEngine.images(); | ||
yield* Console.log(data); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "images", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,10 @@ | ||
#!/usr/bin/env node | ||
import { Command } from "@effect/cli"; | ||
import { Console, Effect } from "effect"; | ||
import { DockerEngine } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
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 DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make("info", {}, () => | ||
export const command = Command.make("info", {}, () => | ||
Effect.gen(function* () { | ||
const data = yield* DockerEngine.info(); | ||
yield* Console.log(data); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "info", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,10 @@ | ||
#!/usr/bin/env node | ||
import { Command } from "@effect/cli"; | ||
import { Console, Effect } from "effect"; | ||
import { DockerEngine } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
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 DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make("ps", {}, () => | ||
export const command = Command.make("ps", {}, () => | ||
Effect.gen(function* () { | ||
const data = yield* DockerEngine.ps(); | ||
yield* Console.log(data); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "ps", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,15 @@ | ||
#!/usr/bin/env node | ||
import { Command, Options } from "@effect/cli"; | ||
import { Effect } from "effect"; | ||
import { DockerEngine, MobyConvey } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
import * as Effect from "effect/Effect"; | ||
import * as Function from "effect/Function"; | ||
import * as Layer from "effect/Layer"; | ||
|
||
import * as DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import * as Convey from "the-moby-effect/MobyConvey"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make( | ||
export const command = Command.make( | ||
"pull", | ||
{ | ||
image: Cli.Options.text("image"), | ||
image: Options.text("image"), | ||
}, | ||
({ image }) => | ||
Effect.gen(function* () { | ||
const pullStream = DockerEngine.pull({ image }); | ||
yield* Convey.followProgressInConsole(pullStream); | ||
yield* MobyConvey.followProgressInConsole(pullStream); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "pull", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,16 @@ | ||
#!/usr/bin/env node | ||
import { Command, Options } from "@effect/cli"; | ||
import { Console, Effect } from "effect"; | ||
import { DockerEngine } from "the-moby-effect"; | ||
|
||
import * as Cli from "@effect/cli"; | ||
import * as NodeContext from "@effect/platform-node/NodeContext"; | ||
import * as NodeRuntime from "@effect/platform-node/NodeRuntime"; | ||
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 DockerEngine from "the-moby-effect/DockerEngine"; | ||
import * as MobyConnection from "the-moby-effect/MobyConnection"; | ||
import PackageJson from "../package.json" assert { type: "json" }; | ||
|
||
export const command = Cli.Command.make( | ||
export const command = Command.make( | ||
"run", | ||
{ | ||
cmd: Cli.Options.text("cmd"), | ||
image: Cli.Options.text("image"), | ||
cmd: Options.text("cmd"), | ||
image: Options.text("image"), | ||
}, | ||
({ cmd, image }) => | ||
Effect.gen(function* () { | ||
const { Id } = yield* DockerEngine.run({ spec: { Cmd: [cmd], Image: image } }); | ||
yield* Console.log(Id); | ||
}) | ||
); | ||
|
||
const DockerLive = Function.pipe( | ||
MobyConnection.connectionOptionsFromDockerHostEnvironmentVariable, | ||
Effect.map(DockerEngine.layerNodeJS), | ||
Layer.unwrapEffect | ||
); | ||
|
||
const cli = Cli.Command.run(command, { | ||
name: "run", | ||
version: PackageJson.version, | ||
}); | ||
|
||
Effect.suspend(() => cli(process.argv.slice(2))).pipe( | ||
Effect.provide(DockerLive), | ||
Effect.provide(NodeContext.layer), | ||
NodeRuntime.runMain | ||
); |
Oops, something went wrong.