Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 99 lines (93 sloc) 3.215 kb
4b78eac @yogsototh Initial yesod commit
authored
1 # Free deployment to Heroku.
2 #
3 # !! Warning: You must use a 64 bit machine to compile !!
4 #
5 # This could mean using a virtual machine. Give your VM as much memory as you can to speed up linking.
6 #
7 # Basic Yesod setup:
8 #
9 # * Move this file out of the deploy directory and into your root directory
10 #
11 # mv deploy/Procfile ./
12 #
13 # * Create an empty package.json
14 # echo '{ "name": "yosog", "version": "0.0.1", "dependencies": {} }' >> package.json
15 #
16 # Postgresql Yesod setup:
17 #
18 # * add code to read the DATABASE_URL environment variable.
19 #
20 # import System.Environment
21 # main = do
22 # # parse env variable
23 # durl <- getEnv "DATABASE_URL"
24 # # pass settings to withConnectionPool instead of directly using loadConnStr
25 # defaultMain (fromArgsExtra loadExtra) withYesodHeroku
26 #
27 # * add a dependency on the "heroku" package in your cabal file
28 #
29 # * add code in Application.hs to turn the url into connection parameters. The below works for Postgresql.
30 #
31 # #ifdef !DEVELOPMENT
32 # import qualified Web.Heroku
33 # #endif
34 #
35 #
36 # canonicalizeKey :: (Text, val) -> (Text, val)
37 # canonicalizeKey ("dbname", val) = ("database", val)
38 # canonicalizeKey pair = pair
39 #
40 # toMapping :: [(key, val)] -> DO.Object key val
41 # toMapping = DO.Mapping . map (\(key, val) -> (key, DO.Scalar val))
42 #
43 # combineMappings :: DO.Object key val -> DO.Object key val -> DO.Object key val
44 # combineMappings (DO.Mapping m1) (DO.Mapping m2) = DO.Mapping $ m1 ++ m2
45 # combineMappings _ _ = error "Data.Object is not a Mapping."
46 #
47 # loadHerokuConfig :: DO.TextObject -> IO Settings.PersistConfig
48 # loadHerokuConfig ymlenv = do
49 # #if DEVELOPMENT
50 # let urlMap = DO.Mapping []
51 # #else
52 # urlMap <- Web.Heroku.dbConnParams >>= return . toMapping . map canonicalizeKey
53 # #endif
54 # either error return $ Database.Persist.Base.loadConfig (combineMappings urlMap ymlenv)
55 #
56 #
57 # withYesodHeroku :: AppConfig DefaultEnv () -> Logger -> (Application -> IO ()) -> IO ()
58 # withYesodHeroku conf logger f = do
59 # s <- staticSite
60 # dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf) loadHerokuConfig
61 # Database.Persist.Base.withPool (dbconf :: Settings.PersistConfig) $ \p -> do
62 # Database.Persist.Base.runPool dbconf (runMigration migrateAll) p
63 # let h = YesodHeroku conf logger s p
64 # defaultRunner (f . logWare) h
65 # where
66 # #ifdef DEVELOPMENT
67 # logWare = logStdoutDev
68 # #else
69 # logWare = logStdout
70 # #endif
71
72
73
74 # Heroku setup:
75 # Find the Heroku guide. Roughly:
76 #
77 # * sign up for a heroku account and register your ssh key
78 # * create a new application on the *cedar* stack
79 #
80 # * make your Yesod project the git repository for that application
81 # * create a deploy branch
82 #
83 # git checkout -b deploy
84 #
85 # Repeat these steps to deploy:
86 # * add your web executable binary (referenced below) to the git repository
87 #
88 # git checkout deploy
89 # git add ./dist/build/yosog/yosog
90 # git commit -m deploy
91 #
92 # * push to Heroku
93 #
94 # git push heroku deploy:master
95
96
97 # Heroku configuration that runs your app
98 web: ./dist/build/yosog/yosog production -p $PORT
Something went wrong with that request. Please try again.