mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-01-12 04:08:30 +01: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 qualified Data.Map as M
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.Text (Text)
|
||||
import Data.Text (Text, pack)
|
||||
import qualified Data.Text as T
|
||||
import Data.Text.Encoding (decodeUtf8)
|
||||
import LoadEnv
|
||||
import Network.HTTP.Conduit
|
||||
import Network.Wai.Handler.Warp (runEnv)
|
||||
import System.Environment (getEnv)
|
||||
import System.Environment (getEnv, lookupEnv)
|
||||
import Yesod
|
||||
import Yesod.Auth
|
||||
import Yesod.Auth.OAuth2.BattleNet
|
||||
@ -50,6 +50,7 @@ import Yesod.Auth.OAuth2.Upcase
|
||||
data App = App
|
||||
{ appHttpManager :: Manager
|
||||
, appAuthPlugins :: [AuthPlugin App]
|
||||
, appAppRoot :: Text
|
||||
}
|
||||
|
||||
mkYesod "App" [parseRoutes|
|
||||
@ -59,7 +60,7 @@ mkYesod "App" [parseRoutes|
|
||||
|
||||
instance Yesod App where
|
||||
-- see https://github.com/thoughtbot/yesod-auth-oauth2/issues/87
|
||||
approot = ApprootStatic "http://localhost:3000"
|
||||
approot = ApprootMaster appAppRoot
|
||||
|
||||
instance YesodAuth App where
|
||||
type AuthId App = Text
|
||||
@ -146,6 +147,12 @@ mkFoundation = do
|
||||
, loadPlugin oauth2Upcase "UPCASE"
|
||||
]
|
||||
|
||||
appAppRoot <- do
|
||||
root <- lookupEnv "APPROOT"
|
||||
return $ pack $ case root of
|
||||
Nothing -> "http://localhost:3000"
|
||||
Just url -> url
|
||||
|
||||
return App {..}
|
||||
where
|
||||
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