diff --git a/src/haskell/exe/Main.hs b/src/haskell/exe/Main.hs index 3fa7f19..4d64ba1 100644 --- a/src/haskell/exe/Main.hs +++ b/src/haskell/exe/Main.hs @@ -112,6 +112,7 @@ parseCommand = <> commandDC runEvalAndDC "top" "Display the running processes" <> commandDC runEvalAndDC "unpause" "Unpause services" <> commandDC runBuildAndDC "up" "Create and start containers" + <> commandDC runEvalAndDC "deploy" "Deploy a new stack or update an existing stack" <> commandDC runDC "version" "Show the Docker-Compose version information" <> metavar "DOCKER-COMPOSE-COMMAND" @@ -164,7 +165,10 @@ callDC cmd dopts opts shouldLoadImages path = do let firstOpts = projectArgs extendedInfo <> commonArgs opts DockerCompose.run DockerCompose.Args { files = [path] - , otherArgs = firstOpts ++ [cmd] ++ unDockerComposeArgs dopts + , otherArgs = case cmd of + "deploy" -> unDockerComposeArgs dopts ++ toList (projectName extendedInfo) + _ -> firstOpts ++ [cmd] ++ unDockerComposeArgs dopts + , useSwarm = cmd == "deploy" } projectArgs :: ExtendedInfo -> [Text] @@ -314,6 +318,7 @@ runExec detach privileged user noTTY index envs workDir service commandAndArgs o DockerCompose.run DockerCompose.Args { files = [path] , otherArgs = projectArgs extendedInfo <> commonArgs opts <> args + , useSwarm = False } main :: IO () diff --git a/src/haskell/lib/Arion/DockerCompose.hs b/src/haskell/lib/Arion/DockerCompose.hs index f44d86f..f3c4840 100644 --- a/src/haskell/lib/Arion/DockerCompose.hs +++ b/src/haskell/lib/Arion/DockerCompose.hs @@ -8,14 +8,20 @@ import System.Process data Args = Args { files :: [FilePath] , otherArgs :: [Text] + , useSwarm :: Bool } run :: Args -> IO () run args = do - let fileArgs = files args >>= \f -> ["--file", f] - allArgs = fileArgs ++ map toS (otherArgs args) + let (executable, fileParam) = case useSwarm args of + False -> ("docker-compose", "--file") + True -> ("docker", "--compose-file") + fileArgs = files args >>= \f -> [fileParam, f] + allArgs = case useSwarm args of + False -> fileArgs ++ map toS (otherArgs args) + True -> ["stack", "deploy"] ++ fileArgs ++ map toS (otherArgs args) - procSpec = proc "docker-compose" allArgs + procSpec = proc executable allArgs -- hPutStrLn stderr ("Running docker-compose with " <> show allArgs :: Text)