on master help sign in
Merge pull request #358 from obsidiansystems/dont-copy-config

Don't copy the dev config into the deployment when using `ob deploy i…

commit1eeff45d25a2f2dd2ecd7cf04083d77132fc3224 authorAli Abrar <aliabrar@gmail.com> dateThu 21 Feb 2019, 08:36 (8 years ago) parentc6f446d456e0e9
2 files changed+15−11
lib/command/src/Obelisk/Command.hs+1−2 lib/command/src/Obelisk/Command/Deploy.hs+14−9
lib/command/src/Obelisk/Command.hs+1−2
@@ -331,8 +331,7 @@ ob = \case
331331 route = _deployInitOpts_route deployOpts
332332 adminEmail = _deployInitOpts_adminEmail deployOpts
333333 enableHttps = _deployInitOpts_enableHttps deployOpts
334− deployInit thunkPtr (root </> "config") deployDir
335− sshKeyPath hostname route adminEmail enableHttps
334+ deployInit thunkPtr deployDir sshKeyPath hostname route adminEmail enableHttps
336335 DeployCommand_Push remoteBuilder -> do
337336 deployPath <- liftIO $ canonicalizePath "."
338337 deployPush deployPath $ case remoteBuilder of
lib/command/src/Obelisk/Command/Deploy.hs+14−9
@@ -47,33 +47,38 @@ deployInit
4747 => ThunkPtr
4848 -> FilePath
4949 -> FilePath
50− -> FilePath
5150 -> [String] -- ^ hostnames
5251 -> String -- ^ route
5352 -> String -- ^ admin email
5453 -> Bool -- ^ enable https
5554 -> m ()
56−deployInit thunkPtr configDir deployDir sshKeyPath hostnames route adminEmail enableHttps = do
57− (hasConfigDir, localKey) <- withSpinner ("Preparing " <> T.pack deployDir) $ do
58− hasConfigDir <- liftIO $ do
59− createDirectoryIfMissing True deployDir
60− doesDirectoryExist configDir
55+deployInit thunkPtr deployDir sshKeyPath hostnames route adminEmail enableHttps = do
56+ localKey <- withSpinner ("Preparing " <> T.pack deployDir) $ do
6157 localKey <- liftIO (doesFileExist sshKeyPath) >>= \case
6258 False -> failWith $ T.pack $ "ob deploy init: file does not exist: " <> sshKeyPath
6359 True -> pure $ deployDir </> "ssh_key"
6460 callProcessAndLogOutput (Notice, Error) $
6561 proc "cp" [sshKeyPath, localKey]
6662 liftIO $ setFileMode localKey $ ownerReadMode .|. ownerWriteMode
67− return $ (hasConfigDir, localKey)
63+ return localKey
6864 withSpinner "Validating configuration" $ do
6965 void $ getHostFromRoute enableHttps route -- make sure that hostname is present
7066 forM_ hostnames $ \hostname -> do
7167 putLog Notice $ "Verifying host keys (" <> T.pack hostname <> ")"
7268 -- Note: we can't use a spinner here as this function will prompt the user.
7369 verifyHostKey (deployDir </> "backend_known_hosts") localKey hostname
74− when hasConfigDir $ withSpinner "Importing project configuration" $ do
70+ --IMPORTANT: We cannot copy config directory from the development project to
71+ --the deployment directory. If we do, it's very likely someone will
72+ --accidentally create a production deployment that uses development
73+ --credentials to connect to some resources. This could result in, e.g.,
74+ --production data backed up to a dev environment.
75+ withSpinner "Creating project configuration directories" $ do
7576 callProcessAndLogOutput (Notice, Error) $
76− proc "cp" [ "-r" , "-T" , configDir , deployDir </> "config"]
77+ proc "mkdir" [ "-p"
78+ , deployDir </> "config" </> "backend"
79+ , deployDir </> "config" </> "common"
80+ , deployDir </> "config" </> "frontend"
81+ ]
7782 withSpinner "Writing deployment configuration" $ do
7883 writeDeployConfig deployDir "backend_hosts" $ unlines hostnames
7984 writeDeployConfig deployDir "enable_https" $ show enableHttps