Update standalone dockerfile and add support for config via env vars
This commit is contained in:
parent
274b5465f6
commit
92b3481828
3 changed files with 10 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
|||
FROM docker.io/alpine:3.11
|
||||
FROM docker.io/alpine:3.14
|
||||
|
||||
RUN apk add --no-cache \
|
||||
py3-aiohttp \
|
||||
|
|
|
@ -27,7 +27,7 @@ from ruamel.yaml import YAML
|
|||
from ruamel.yaml.comments import CommentedMap
|
||||
import sqlalchemy as sql
|
||||
|
||||
from mautrix.util.config import RecursiveDict
|
||||
from mautrix.util.config import RecursiveDict, BaseMissingError
|
||||
from mautrix.util.db import Base
|
||||
from mautrix.types import (UserID, Filter, RoomFilter, RoomEventFilter, StrippedStateEvent,
|
||||
EventType, Membership)
|
||||
|
@ -55,6 +55,8 @@ config = Config(args.config, args.base_config)
|
|||
config.load()
|
||||
try:
|
||||
config.update()
|
||||
except BaseMissingError:
|
||||
print("No example config found, not updating config")
|
||||
except Exception as e:
|
||||
print("Failed to update config:", e)
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@ from mautrix.util.config import BaseFileConfig, ConfigUpdateHelper
|
|||
|
||||
|
||||
class Config(BaseFileConfig):
|
||||
def __getitem__(self, key: str) -> Any:
|
||||
try:
|
||||
return os.environ[f"MAUBOT_{key.replace('.', '_').upper()}"]
|
||||
except KeyError:
|
||||
return super().__getitem__(key)
|
||||
|
||||
def do_update(self, helper: ConfigUpdateHelper) -> None:
|
||||
copy, _, base = helper
|
||||
copy("user.credentials.id")
|
||||
|
|
Loading…
Reference in a new issue