Skip to content

Commit

Permalink
Fix --docker for Windows. Fix #2421.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdziadkiewicz committed Jun 7, 2020
1 parent 9dcef52 commit e11adb4
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/Stack/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ getCmdArgs
getCmdArgs docker imageInfo isRemoteDocker = do
config <- view configL
deUser <-
if fromMaybe (not isRemoteDocker) (dockerSetUser docker)
if fromMaybe (not isRemoteDocker) (dockerSetUser docker) && not osIsWindows
then liftIO $ do
duUid <- User.getEffectiveUserID
duGid <- User.getEffectiveGroupID
Expand Down Expand Up @@ -244,7 +244,7 @@ runContainerAndExit = do
liftIO
(Files.fileExist
(toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)))
when (sshDirExists && not sshSandboxDirExists)
when (sshDirExists && not sshSandboxDirExists && not osIsWindows)
(liftIO
(Files.createSymbolicLink
(toFilePathNoTrailingSep sshDir)
Expand All @@ -255,16 +255,16 @@ runContainerAndExit = do
[["create"
,"--net=host"
,"-e",inContainerEnvVar ++ "=1"
,"-e",stackRootEnvVar ++ "=" ++ toFilePathNoTrailingSep stackRoot
,"-e",stackRootEnvVar ++ "=" ++ toLinuxStylePath (toFilePathNoTrailingSep stackRoot)
,"-e",platformVariantEnvVar ++ "=dk" ++ platformVariant
,"-e","HOME=" ++ toFilePathNoTrailingSep sandboxHomeDir
,"-e","HOME=" ++ toLinuxStylePath (toFilePathNoTrailingSep sandboxHomeDir)
,"-e","PATH=" ++ T.unpack newPathEnv
,"-e","PWD=" ++ toFilePathNoTrailingSep pwd
,"-v",toFilePathNoTrailingSep homeDir ++ ":" ++ toFilePathNoTrailingSep homeDir ++ mountSuffix
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toFilePathNoTrailingSep stackRoot ++ mountSuffix
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot ++ mountSuffix
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir ++ mountSuffix
,"-w",toFilePathNoTrailingSep pwd]
,"-e","PWD=" ++ toLinuxStylePath (toFilePathNoTrailingSep pwd)
,"-v",toFilePathNoTrailingSep homeDir ++ ":" ++ toLinuxStylePath (toFilePathNoTrailingSep homeDir ++ mountSuffix)
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toLinuxStylePath (toFilePathNoTrailingSep stackRoot ++ mountSuffix)
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toLinuxStylePath (toFilePathNoTrailingSep projectRoot ++ mountSuffix)
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toLinuxStylePath (toFilePathNoTrailingSep sandboxHomeDir ++ mountSuffix)
,"-w", toLinuxStylePath (toFilePathNoTrailingSep pwd)]
,case muserEnv of
Nothing -> []
Just userEnv -> ["-e","USER=" ++ userEnv]
Expand Down Expand Up @@ -338,6 +338,13 @@ runContainerAndExit = do
mountArg mountSuffix (Mount host container) =
["-v",host ++ ":" ++ container ++ mountSuffix]
sshRelDir = relDirDotSsh
toLinuxStylePath s | osIsWindows =
T.pack s
& T.replace ":\\" "/"
& T.replace "\\" "/"
& T.unpack
& ("/"++)
| otherwise = s

-- | Inspect Docker image or container.
inspect :: (HasProcessContext env, HasLogFunc env)
Expand Down

0 comments on commit e11adb4

Please sign in to comment.