From de2a95dc7d6eb890e67a540e90d4ec24d99972d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Fri, 5 Nov 2021 09:44:34 +0100 Subject: [PATCH] Add Dockerfile --- .env.sample | 6 +++-- Dockerfile | 32 ++++++++++++++++++++++++++ README.md | 4 ++-- log-config-dev.yaml => log-config.yaml | 0 src/runboat/deps.py | 4 ++-- src/runboat/settings.py | 4 ++-- 6 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 Dockerfile rename log-config-dev.yaml => log-config.yaml (100%) diff --git a/.env.sample b/.env.sample index b3c606b..d0086d6 100644 --- a/.env.sample +++ b/.env.sample @@ -1,6 +1,6 @@ RUNBOAT_SUPPORTED_REPOS=["OCA/mis-builder", "shopinvader/odoo-shopinvader", "OCA/server-env"] -RUNBOAT_ADMIN_USER="admin" -RUNBOAT_ADMIN_PASSWD="admin" +RUNBOAT_API_ADMIN_USER="admin" +RUNBOAT_API_ADMIN_PASSWD="admin" RUNBOAT_BUILD_NAMESPACE=runboat-builds RUNBOAT_BUILD_PGHOST=postgres14.runboat-builds-db RUNBOAT_BUILD_PGPORT=5432 @@ -8,3 +8,5 @@ RUNBOAT_BUILD_PGUSER=runboat-build RUNBOAT_BUILD_PGPASSWORD=... RUNBOAT_BUILD_ADMIN_PASSWD=... RUNBOAT_BUILD_DOMAIN=runboat.odoo-community.org +RUNBOAT_GITHUB_TOKEN= +RUNBOAT_LOG_CONFIG=log-config.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fd36e43 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.10 + +LABEL maintainer="Stéphane Bidoul" + +RUN pip install --no-cache-dir --upgrade "pip>=21.3.1" + +COPY requirements.txt /tmp/requirements.txt +RUN pip install --no-cache-dir -r /tmp/requirements.txt + +COPY src /app +ENV PYTHONPATH=/app + +COPY log-config.yaml /etc/runboat-log-config.yaml + +ENV RUNBOAT_SUPPORTED_REPOS='["oca/server-env", "oca/mis-builder"]' +ENV RUNBOAT_API_ADMIN_USER="admin" +ENV RUNBOAT_API_ADMIN_PASSWD= +ENV RUNBOAT_BUILD_NAMESPACE=runboat-builds +ENV RUNBOAT_BUILD_PGHOST=postgres14.runboat-builds-db +ENV RUNBOAT_BUILD_PGPORT=5432 +ENV RUNBOAT_BUILD_PGUSER=runboat-build +ENV RUNBOAT_BUILD_PGPASSWORD= +ENV RUNBOAT_BUILD_ADMIN_PASSWD= +ENV RUNBOAT_BUILD_DOMAIN=runboat.example.com +ENV RUNBOAT_GITHUB_TOKEN= +ENV RUNBOAT_LOG_CONFIG=/etc/runboat-log-config.yaml + +ENV KUBECONFIG=/run/kubeconfig + +EXPOSE 8000 + +CMD [ "gunicorn", "-w", "1", "-k", "runboat.uvicorn.RunboatUvicornWorker", "runboat.app:app"] diff --git a/README.md b/README.md index 0337e8c..7cb742d 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ in a different cluster. - setup environment variables (start from `.env.sample`) - create a virtualenv, make sure to have pip>=21.3.1 and `pip install -e .` -- run with `uvicorn runboat.app:app --log-config=log-config-dev.yaml` +- run with `uvicorn runboat.app:app --log-config=log-config.yaml` ## Running in production @@ -128,7 +128,7 @@ MVP: - k8s init container timeout - better error handling in API (return 400 on user errors) - basic tests -- build and publish runboat container image +- publish runboat container image - look at other TODO in code to see if anything important remains - basic UI (single page with a combo box to select repo and show builds by branch/pr, with start/stop buttons) diff --git a/log-config-dev.yaml b/log-config.yaml similarity index 100% rename from log-config-dev.yaml rename to log-config.yaml diff --git a/src/runboat/deps.py b/src/runboat/deps.py index 410076c..8d2afff 100644 --- a/src/runboat/deps.py +++ b/src/runboat/deps.py @@ -11,11 +11,11 @@ security = HTTPBasic() def authenticated(credentials: HTTPBasicCredentials = Depends(security)) -> None: correct_username = secrets.compare_digest( credentials.username, - settings.admin_user, + settings.api_admin_user, ) correct_password = secrets.compare_digest( credentials.password, - settings.admin_passwd, + settings.api_admin_passwd, ) if not (correct_username and correct_password): raise HTTPException( diff --git a/src/runboat/settings.py b/src/runboat/settings.py index 997d0a8..c261c1c 100644 --- a/src/runboat/settings.py +++ b/src/runboat/settings.py @@ -4,8 +4,8 @@ from pydantic import BaseSettings class Settings(BaseSettings): - admin_user: str - admin_passwd: str + api_admin_user: str + api_admin_passwd: str supported_repos: set[str] max_initializing: int = 2 max_started: int = 6