-
Notifications
You must be signed in to change notification settings - Fork 332
Optional YAML configuration for Brig #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ library | |
| , transformers >= 0.3 | ||
| , time >= 1.1 | ||
| , tinylog >= 0.10.2 | ||
| , yaml >= 0.8.22 | ||
|
|
||
| ghc-options: | ||
| -Wall | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| module Util.Options where | ||
|
|
||
| import Data.Aeson (FromJSON) | ||
| import Data.Maybe (fromMaybe) | ||
| import Data.Monoid | ||
| import Data.Yaml (ParseException, decodeFileEither) | ||
| import Options.Applicative | ||
| import System.Directory | ||
| import System.Environment (getArgs) | ||
| import System.IO (hPutStrLn, stderr) | ||
|
|
||
| getOptions :: (FromJSON a) => String -> Parser a -> FilePath -> IO a | ||
| getOptions desc parser defaultPath = do | ||
| path <- parseConfigPath defaultPath (mkDesc desc) | ||
| file <- doesFileExist path | ||
| if file | ||
| then do | ||
| configFile <- decodeConfigFile path | ||
| case configFile of | ||
| Left e -> fail $ show e | ||
| Right opts -> return opts | ||
| else do | ||
| hPutStrLn stderr $ | ||
| "Config file at " ++ | ||
| path ++ | ||
| " does not exist, falling back to command-line arguments. \n" | ||
| execParser (info (helper <*> parser) (mkDesc desc)) | ||
|
|
||
| decodeConfigFile :: (FromJSON a) => FilePath -> IO (Either ParseException a) | ||
| decodeConfigFile = decodeFileEither | ||
|
|
||
| parseConfigPath :: FilePath -> InfoMod String -> IO String | ||
| parseConfigPath defaultPath desc = do | ||
| args <- getArgs | ||
| let result = | ||
| getParseResult $ | ||
| execParserPure defaultPrefs (info (helper <*> pathParser) desc) args | ||
| pure $ fromMaybe defaultPath result | ||
| where | ||
| pathParser :: Parser String | ||
| pathParser = | ||
| strOption $ | ||
| long "config-file" <> short 'c' <> help "Config file to load" <> | ||
| showDefault <> | ||
| value defaultPath | ||
|
|
||
| mkDesc :: String -> InfoMod a | ||
| mkDesc desc = header desc <> fullDesc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Requires docker >= 17.05 (requires support for multi-stage builds) | ||
| # Requires to have created the wire-server-builder and wire-server-deps docker images | ||
|
|
||
| #--- Builder stage --- | ||
| FROM wire-server-builder:alpine as builder | ||
|
|
||
| COPY . /src/wire-server/ | ||
|
|
||
| RUN cd /src/wire-server/services/brig && make install | ||
|
|
||
| #--- Minified stage --- | ||
| FROM wire-server-deps:alpine | ||
|
|
||
| ARG executable | ||
| COPY --from=builder /src/wire-server/services/brig/dist/${executable} /usr/bin/${exectuable} | ||
| COPY --from=builder /src/wire-server/services/brig/deb/opt/brig/templates/ /usr/share/wire/templates/ | ||
|
|
||
| # ARGs are not available at runtime, create symlink at build time | ||
| # more info: https://stackoverflow.com/questions/40902445/using-variable-interpolation-in-string-in-docker | ||
| RUN ln -s /usr/bin/${executable} /usr/bin/service | ||
| ENTRYPOINT ["/usr/bin/service"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the motivation of changing the type here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test-suite implies running them as part of the build, which in the current code is worked around by requiring a certain environment variable. In reality, it is actually some sort of mix between a test and an executable.
This way, we should be able to build things (as before) without the need of a hack in the test executable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Please then also take out this hacky line in the Makefile: https://github.com/wireapp/wire-server/blob/develop/services/brig/Makefile#L31