Add setting for custom runtime of containers (#10)
This commit is contained in:
parent
6598462227
commit
d83283466c
3 changed files with 14 additions and 3 deletions
|
@ -13,6 +13,9 @@ port: 8081
|
||||||
|
|
||||||
# The default language configuration.
|
# The default language configuration.
|
||||||
defaultLanguage:
|
defaultLanguage:
|
||||||
|
# The OCI runtime to use when running the container.
|
||||||
|
runtime: runc
|
||||||
|
|
||||||
# The maximum memory and swap usage (separately) of a container.
|
# The maximum memory and swap usage (separately) of a container.
|
||||||
memory: 256m
|
memory: 256m
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ type LanguageName = T.Text
|
||||||
|
|
||||||
data Language = Language
|
data Language = Language
|
||||||
{ _name :: LanguageName
|
{ _name :: LanguageName
|
||||||
|
, _runtime :: T.Text
|
||||||
, _memory :: T.Text
|
, _memory :: T.Text
|
||||||
, _cpus :: Double
|
, _cpus :: Double
|
||||||
, _timeout :: Int
|
, _timeout :: Int
|
||||||
|
@ -42,7 +43,8 @@ data Config = Config
|
||||||
makeFieldLabelsWith classUnderscoreNoPrefixFields ''Config
|
makeFieldLabelsWith classUnderscoreNoPrefixFields ''Config
|
||||||
|
|
||||||
data DefaultLanguage = DefaultLanguage
|
data DefaultLanguage = DefaultLanguage
|
||||||
{ _memory :: T.Text
|
{ _runtime :: T.Text
|
||||||
|
, _memory :: T.Text
|
||||||
, _cpus :: Double
|
, _cpus :: Double
|
||||||
, _timeout :: Int
|
, _timeout :: Int
|
||||||
, _concurrent :: Int
|
, _concurrent :: Int
|
||||||
|
@ -54,7 +56,8 @@ makeFieldLabelsWith classUnderscoreNoPrefixFields ''DefaultLanguage
|
||||||
|
|
||||||
instance FromJSON DefaultLanguage where
|
instance FromJSON DefaultLanguage where
|
||||||
parseJSON = withObject "default language" $ \m -> DefaultLanguage
|
parseJSON = withObject "default language" $ \m -> DefaultLanguage
|
||||||
<$> m .: "memory"
|
<$> m .: "runtime"
|
||||||
|
<*> m .: "memory"
|
||||||
<*> m .: "cpus"
|
<*> m .: "cpus"
|
||||||
<*> m .: "timeout"
|
<*> m .: "timeout"
|
||||||
<*> m .: "concurrent"
|
<*> m .: "concurrent"
|
||||||
|
@ -63,6 +66,7 @@ instance FromJSON DefaultLanguage where
|
||||||
|
|
||||||
data RawLanguage = RawLanguage
|
data RawLanguage = RawLanguage
|
||||||
{ _name :: LanguageName
|
{ _name :: LanguageName
|
||||||
|
, _runtime :: Maybe T.Text
|
||||||
, _memory :: Maybe T.Text
|
, _memory :: Maybe T.Text
|
||||||
, _cpus :: Maybe Double
|
, _cpus :: Maybe Double
|
||||||
, _timeout :: Maybe Int
|
, _timeout :: Maybe Int
|
||||||
|
@ -76,6 +80,7 @@ makeFieldLabelsWith classUnderscoreNoPrefixFields ''RawLanguage
|
||||||
instance FromJSON RawLanguage where
|
instance FromJSON RawLanguage where
|
||||||
parseJSON = withObject "language" $ \m -> RawLanguage
|
parseJSON = withObject "language" $ \m -> RawLanguage
|
||||||
<$> m .: "name"
|
<$> m .: "name"
|
||||||
|
<*> m .:? "runtime"
|
||||||
<*> m .:? "memory"
|
<*> m .:? "memory"
|
||||||
<*> m .:? "cpus"
|
<*> m .:? "cpus"
|
||||||
<*> m .:? "timeout"
|
<*> m .:? "timeout"
|
||||||
|
@ -127,6 +132,7 @@ fromRawLanguage :: DefaultLanguage -> RawLanguage -> Language
|
||||||
fromRawLanguage d r =
|
fromRawLanguage d r =
|
||||||
Language
|
Language
|
||||||
{ _name = r ^. #name
|
{ _name = r ^. #name
|
||||||
|
, _runtime = fromMaybe (d ^. #runtime) (r ^. #runtime)
|
||||||
, _memory = fromMaybe (d ^. #memory) (r ^. #memory)
|
, _memory = fromMaybe (d ^. #memory) (r ^. #memory)
|
||||||
, _cpus = fromMaybe (d ^. #cpus) (r ^. #cpus)
|
, _cpus = fromMaybe (d ^. #cpus) (r ^. #cpus)
|
||||||
, _timeout = fromMaybe (d ^. #timeout) (r ^. #timeout)
|
, _timeout = fromMaybe (d ^. #timeout) (r ^. #timeout)
|
||||||
|
|
|
@ -95,7 +95,9 @@ setupContainer lang = do
|
||||||
cnt <- newContainerName lang
|
cnt <- newContainerName lang
|
||||||
logInfo ["Setting up new container ", cs cnt]
|
logInfo ["Setting up new container ", cs cnt]
|
||||||
exec_
|
exec_
|
||||||
[ "docker run --rm --name="
|
[ "docker run --runtime="
|
||||||
|
, cs $ lang ^. #runtime
|
||||||
|
, " --rm --name="
|
||||||
, cs cnt
|
, cs cnt
|
||||||
-- User 1000 will be for setting up the environment
|
-- User 1000 will be for setting up the environment
|
||||||
, " -u1000:1000 -w/tmp/ -dt --net=none --cpus="
|
, " -u1000:1000 -w/tmp/ -dt --net=none --cpus="
|
||||||
|
|
Loading…
Reference in a new issue