Skip to content

Commit b2a182d

Browse files
committed
Docker: pass USER and PWD environment to container
closes commercialhaskell#1715
1 parent 0306810 commit b2a182d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Stack/Docker.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ runContainerAndExit getCmdArgs
271271
bamboo = lookup "bamboo_buildKey" env
272272
jenkins = lookup "JENKINS_HOME" env
273273
msshAuthSock = lookup "SSH_AUTH_SOCK" env
274+
muserEnv = lookup "USER" env
274275
isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
275276
image = dockerImage docker
276277
when (isRemoteDocker &&
@@ -322,10 +323,14 @@ runContainerAndExit getCmdArgs
322323
,"-e",platformVariantEnvVar ++ "=dk" ++ platformVariant
323324
,"-e","HOME=" ++ toFilePathNoTrailingSep sandboxHomeDir
324325
,"-e","PATH=" ++ T.unpack newPathEnv
326+
,"-e","PWD=" ++ toFilePathNoTrailingSep pwd
325327
,"-v",toFilePathNoTrailingSep stackRoot ++ ":" ++ toFilePathNoTrailingSep stackRoot
326328
,"-v",toFilePathNoTrailingSep projectRoot ++ ":" ++ toFilePathNoTrailingSep projectRoot
327329
,"-v",toFilePathNoTrailingSep sandboxHomeDir ++ ":" ++ toFilePathNoTrailingSep sandboxHomeDir
328330
,"-w",toFilePathNoTrailingSep pwd]
331+
,case muserEnv of
332+
Nothing -> []
333+
Just userEnv -> ["-e","USER=" ++ userEnv]
329334
,if sshDirExists
330335
then ["-v",toFilePathNoTrailingSep sshDir ++ ":" ++
331336
toFilePathNoTrailingSep (sandboxHomeDir </> sshRelDir)]

0 commit comments

Comments
 (0)