@@ -47,33 +47,38 @@ deployInit
47 => ThunkPtr
47 => ThunkPtr
48 -> FilePath
48 -> FilePath
49 -> FilePath
49 -> FilePath
51 -> [String] -- ^ hostnames
50 -> [String] -- ^ hostnames
52 -> String -- ^ route
51 -> String -- ^ route
53 -> String -- ^ admin email
52 -> String -- ^ admin email
54 -> Bool -- ^ enable https
53 -> Bool -- ^ enable https
56−deployInit thunkPtr configDir deployDir sshKeyPath hostnames route adminEmail enableHttps = do
55+deployInit thunkPtr deployDir sshKeyPath hostnames route adminEmail enableHttps = do
57− (hasConfigDir, localKey) <- withSpinner ("Preparing " <> T.pack deployDir) $ do
56+ localKey <- withSpinner ("Preparing " <> T.pack deployDir) $ do
58− hasConfigDir <- liftIO $ do
59− createDirectoryIfMissing True deployDir
60− doesDirectoryExist configDir
61 localKey <- liftIO (doesFileExist sshKeyPath) >>= \case
57 localKey <- liftIO (doesFileExist sshKeyPath) >>= \case
62 False -> failWith $ T.pack $ "ob deploy init: file does not exist: " <> sshKeyPath
58 False -> failWith $ T.pack $ "ob deploy init: file does not exist: " <> sshKeyPath
63 True -> pure $ deployDir </> "ssh_key"
59 True -> pure $ deployDir </> "ssh_key"
64 callProcessAndLogOutput (Notice, Error) $
60 callProcessAndLogOutput (Notice, Error) $
65 proc "cp" [sshKeyPath, localKey]
61 proc "cp" [sshKeyPath, localKey]
66 liftIO $ setFileMode localKey $ ownerReadMode .|. ownerWriteMode
62 liftIO $ setFileMode localKey $ ownerReadMode .|. ownerWriteMode
67− return $ (hasConfigDir, localKey)
63+ return localKey
68 withSpinner "Validating configuration" $ do
64 withSpinner "Validating configuration" $ do
69 void $ getHostFromRoute enableHttps route -- make sure that hostname is present
65 void $ getHostFromRoute enableHttps route -- make sure that hostname is present
70 forM_ hostnames $ \hostname -> do
66 forM_ hostnames $ \hostname -> do
71 putLog Notice $ "Verifying host keys (" <> T.pack hostname <> ")"
67 putLog Notice $ "Verifying host keys (" <> T.pack hostname <> ")"
72 -- Note: we can't use a spinner here as this function will prompt the user.
68 -- Note: we can't use a spinner here as this function will prompt the user.
73 verifyHostKey (deployDir </> "backend_known_hosts") localKey hostname
69 verifyHostKey (deployDir </> "backend_known_hosts") localKey hostname
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.
74− when hasConfigDir $ withSpinner "Importing project configuration" $ do
75+ withSpinner "Creating project configuration directories" $ do
75 callProcessAndLogOutput (Notice, Error) $
76 callProcessAndLogOutput (Notice, Error) $
78+ , deployDir </> "config" </> "backend"
79+ , deployDir </> "config" </> "common"
76− proc "cp" [ "-r" , "-T" , configDir , deployDir </> "config"]
80+ , deployDir </> "config" </> "frontend"
77 withSpinner "Writing deployment configuration" $ do
82 withSpinner "Writing deployment configuration" $ do
78 writeDeployConfig deployDir "backend_hosts" $ unlines hostnames
83 writeDeployConfig deployDir "backend_hosts" $ unlines hostnames
79 writeDeployConfig deployDir "enable_https" $ show enableHttps
84 writeDeployConfig deployDir "enable_https" $ show enableHttps