towards docker container

This commit is contained in:
Filip Gralinski 2018-06-01 07:48:04 +02:00
parent 0662522a44
commit f771b04f69
5 changed files with 48 additions and 6 deletions

View File

@ -2,6 +2,7 @@
module Application
( getApplicationDev
, appMain
, appSelfContainedMain
, develMain
, makeFoundation
-- * for DevelMain
@ -21,8 +22,6 @@ import Network.Wai.Handler.Warp (Settings, defaultSettings,
defaultShouldDisplayException,
runSettings, setHost,
setOnException, setPort, getPort)
import Network.Wai.Handler.FastCGI (run)
import Network.Wai.Middleware.RequestLogger (Destination (Logger),
IPAddrSource (..),
OutputFormat (..), destination,
@ -149,7 +148,6 @@ develMain :: IO ()
develMain = develMainHelper getApplicationDev
-- | The @main@ function for an executable running this site.
appMain :: IO ()
appMain = do
-- Get the settings from all relevant sources
settings <- loadAppSettingsArgs
@ -167,7 +165,27 @@ appMain = do
-- Run the application with Warp
-- runSettings (warpSettings foundation) app
run app
return app
-- | The @main@ function for an executable running this site.
appSelfContainedMain :: IO ()
appSelfContainedMain = do
-- Get the settings from all relevant sources
settings <- loadAppSettingsArgs
-- fall back to compile-time values, set to [] to require values at runtime
[configSettingsYmlValue]
-- allow environment variables to override
useEnv
-- Generate the foundation from the settings
foundation <- makeFoundation settings
-- Generate a WAI Application from the foundation
app <- makeApplication foundation
-- Run the application with Warp
runSettings (warpSettings foundation) app
--------------------------------------------------------------
-- Functions for DevelMain.hs (a way to run the app from GHCi)

5
app/main-bin.hs Normal file
View File

@ -0,0 +1,5 @@
import Prelude (IO)
import Application (appSelfContainedMain)
main :: IO ()
main = appSelfContainedMain

View File

@ -1,5 +1,8 @@
import Prelude (IO)
import Network.Wai.Handler.FastCGI (run)
import Application (appMain)
main :: IO ()
main = appMain
main = do
app <- appMain
run app

View File

@ -126,7 +126,6 @@ library
, yesod-table
, regex-tdfa
, optparse-applicative
, wai-handler-fastcgi
, blaze-markup
, blaze-html
, conduit-extra
@ -145,10 +144,21 @@ executable gonito
main-is: main.hs
hs-source-dirs: app
build-depends: base, gonito, wai-handler-fastcgi
ghc-options: -threaded -O2 -rtsopts -with-rtsopts=-N
executable gonito-bin
if flag(library-only)
Buildable: False
main-is: main-bin.hs
hs-source-dirs: app
build-depends: base, gonito
ghc-options: -threaded -O2 -rtsopts -with-rtsopts=-N
test-suite test
type: exitcode-stdio-1.0
main-is: Spec.hs

View File

@ -10,3 +10,9 @@ packages:
extra-dep: true
extra-deps: [../geval,wai-handler-fastcgi-3.0.0.2,murmur3-1.0.3]
resolver: lts-11.9
image:
container:
name: filipg/gonito
base: fpco/stack-run
add:
executables: /usr/local/bin/gonito-bin