mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-04-25 20:27:57 +02:00
Add configuration for heroku deployment of the example app
This commit is contained in:
parent
036458c7a8
commit
1860c21169
33
Dockerfile
Normal file
33
Dockerfile
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
FROM heroku/heroku:18-build
|
||||||
|
|
||||||
|
# Update system and install stack
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
ENV LANG C.UTF-8
|
||||||
|
ENV LC_ALL C.UTF-8
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install sudo haskell-stack \
|
||||||
|
&& apt-get clean
|
||||||
|
|
||||||
|
# Create user "testuser"
|
||||||
|
RUN useradd -m -d /home/testuser -s /bin/bash testuser
|
||||||
|
RUN mkdir -p /etc/sudoers.d \
|
||||||
|
&& echo "testuser ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/testuser \
|
||||||
|
&& chmod 0440 /etc/sudoers.d/testuser
|
||||||
|
ENV HOME /home/testuser
|
||||||
|
WORKDIR /home/testuser
|
||||||
|
USER testuser
|
||||||
|
COPY --chown=testuser package.yaml app
|
||||||
|
COPY --chown=testuser stack.yaml app
|
||||||
|
|
||||||
|
# Update stack and cache dependencies and app in stages
|
||||||
|
ENV PATH="/home/testuser/.local/bin:${PATH}"
|
||||||
|
RUN stack upgrade
|
||||||
|
RUN cd app && stack setup
|
||||||
|
RUN cd app && stack build --only-dependencies Cabal
|
||||||
|
RUN cd app && stack build --only-dependencies yesod
|
||||||
|
|
||||||
|
COPY --chown=testuser . app
|
||||||
|
RUN cd app && stack install --flag yesod-auth-oauth2:example
|
||||||
|
WORKDIR /home/testuser/app
|
||||||
|
|
||||||
|
CMD yesod-auth-oauth2-example
|
||||||
@ -26,13 +26,13 @@ import Data.Aeson.Encode.Pretty
|
|||||||
import Data.ByteString.Lazy (fromStrict, toStrict)
|
import Data.ByteString.Lazy (fromStrict, toStrict)
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text, pack)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Text.Encoding (decodeUtf8)
|
import Data.Text.Encoding (decodeUtf8)
|
||||||
import LoadEnv
|
import LoadEnv
|
||||||
import Network.HTTP.Conduit
|
import Network.HTTP.Conduit
|
||||||
import Network.Wai.Handler.Warp (runEnv)
|
import Network.Wai.Handler.Warp (runEnv)
|
||||||
import System.Environment (getEnv)
|
import System.Environment (getEnv, lookupEnv)
|
||||||
import Yesod
|
import Yesod
|
||||||
import Yesod.Auth
|
import Yesod.Auth
|
||||||
import Yesod.Auth.OAuth2.BattleNet
|
import Yesod.Auth.OAuth2.BattleNet
|
||||||
@ -50,6 +50,7 @@ import Yesod.Auth.OAuth2.Upcase
|
|||||||
data App = App
|
data App = App
|
||||||
{ appHttpManager :: Manager
|
{ appHttpManager :: Manager
|
||||||
, appAuthPlugins :: [AuthPlugin App]
|
, appAuthPlugins :: [AuthPlugin App]
|
||||||
|
, appAppRoot :: Text
|
||||||
}
|
}
|
||||||
|
|
||||||
mkYesod "App" [parseRoutes|
|
mkYesod "App" [parseRoutes|
|
||||||
@ -59,7 +60,7 @@ mkYesod "App" [parseRoutes|
|
|||||||
|
|
||||||
instance Yesod App where
|
instance Yesod App where
|
||||||
-- see https://github.com/thoughtbot/yesod-auth-oauth2/issues/87
|
-- see https://github.com/thoughtbot/yesod-auth-oauth2/issues/87
|
||||||
approot = ApprootStatic "http://localhost:3000"
|
approot = ApprootMaster appAppRoot
|
||||||
|
|
||||||
instance YesodAuth App where
|
instance YesodAuth App where
|
||||||
type AuthId App = Text
|
type AuthId App = Text
|
||||||
@ -146,6 +147,12 @@ mkFoundation = do
|
|||||||
, loadPlugin oauth2Upcase "UPCASE"
|
, loadPlugin oauth2Upcase "UPCASE"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
appAppRoot <- do
|
||||||
|
root <- lookupEnv "APPROOT"
|
||||||
|
return $ pack $ case root of
|
||||||
|
Nothing -> "http://localhost:3000"
|
||||||
|
Just url -> url
|
||||||
|
|
||||||
return App {..}
|
return App {..}
|
||||||
where
|
where
|
||||||
loadPlugin f prefix = do
|
loadPlugin f prefix = do
|
||||||
|
|||||||
5
heroku.yml
Normal file
5
heroku.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
build:
|
||||||
|
docker:
|
||||||
|
web: Dockerfile
|
||||||
|
run:
|
||||||
|
web: yesod-auth-oauth2-example
|
||||||
Loading…
Reference in New Issue
Block a user