Clarify README further, ensure production logger is used when set to PRODUCTION environment
This commit is contained in:
parent
d713f9b4e6
commit
5072fb4df4
16
README.md
16
README.md
@ -42,9 +42,9 @@ Only Nix build instructions are provided below.
|
||||
### Containers
|
||||
1) Clone this repository
|
||||
2) Build the container image (with flakes enabled): `nix build .#purr-container`
|
||||
3) Load the container image
|
||||
- podman load -i result
|
||||
4) NixOS configuration:
|
||||
3) Load the container image: `podman load -i result`
|
||||
4) Pick option 5, 6, or use your favorite process to manage containers and ENV
|
||||
5) NixOS configuration:
|
||||
```
|
||||
virtualisation.oci-containers.containers.purr = {
|
||||
image = "purr";
|
||||
@ -63,9 +63,13 @@ virtualisation.oci-containers.containers.purr = {
|
||||
};
|
||||
};
|
||||
```
|
||||
5) Docker Stack
|
||||
1) Set environment variables in docker-stack.yml or mount a .env file.
|
||||
2) `docker stack deploy -c docker-stack.yml purr`
|
||||
6) Docker Stack
|
||||
1) Copy the docker-stack.yml example and edit as needed.
|
||||
1) `cp examples/docker-stack.yml ./; $EDITOR ./docker-stack.yml`
|
||||
2) Set environment variables:
|
||||
- `cp examples/.env.example ./.env; $EDITOR ./.env`
|
||||
- Or set them in the docker-stack.yml environment declaration.
|
||||
3) Deploy: `docker stack deploy -c docker-stack.yml purr`
|
||||
|
||||
## DEVELOPMENT & SUPPORT
|
||||
|
||||
|
@ -39,6 +39,9 @@ encKey = do
|
||||
adminEmail :: IO String
|
||||
adminEmail = getEnv "ADMINEMAIL"
|
||||
|
||||
getRuntimeEnvironment :: IO String
|
||||
getRuntimeEnvironment = getEnv "ENVIRONMENT"
|
||||
|
||||
appPort :: IO String
|
||||
appPort = getEnv "APPLICATIONPORT"
|
||||
|
||||
|
@ -1,22 +1,28 @@
|
||||
module Core.HTTP ( app ) where
|
||||
|
||||
import Core.Configuration (adminEmail, confLinkLength)
|
||||
import Core.Configuration ( adminEmail
|
||||
, confLinkLength
|
||||
, getRuntimeEnvironment)
|
||||
import Core.Types
|
||||
|
||||
import Core.Templates (renderIndex, renderStyle)
|
||||
import Feature.Generation.HTTP as Generation
|
||||
import Feature.Sharing.HTTP as Sharing
|
||||
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.Trans (liftIO)
|
||||
import Data.Maybe (Maybe (Nothing))
|
||||
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
|
||||
import Network.Wai.Middleware.RequestLogger (logStdout, logStdoutDev)
|
||||
import Network.Wai.Middleware.Static
|
||||
import Web.Scotty
|
||||
|
||||
app :: PurrApp ()
|
||||
app = do
|
||||
app :: String -> PurrApp ()
|
||||
app env = do
|
||||
-- Middleware that are processed on every request
|
||||
middleware logStdoutDev
|
||||
case env of
|
||||
"production" -> middleware logStdout
|
||||
"prod" -> middleware logStdout
|
||||
_ -> middleware logStdoutDev
|
||||
middleware $ staticPolicy (noDots >-> addBase "data/assets/public")
|
||||
|
||||
-- Core Routes
|
||||
|
@ -27,5 +27,6 @@ main = do
|
||||
{- Get the configured port to run on and start the Scotty webserver app
|
||||
defined in HTTP.app -}
|
||||
appPortStr <- Configuration.appPort
|
||||
env <- Configuration.getRuntimeEnvironment
|
||||
let appPort = read appPortStr :: Int
|
||||
scotty appPort HTTP.app
|
||||
scotty appPort (HTTP.app env)
|
||||
|
Loading…
x
Reference in New Issue
Block a user