From d6ffc1bd8e6bcaf1a609ae2a537fad27e60796ea Mon Sep 17 00:00:00 2001 From: Nikhil Jha Date: Mon, 22 Apr 2024 13:53:06 -0700 Subject: [PATCH] :rocket: deploy irc bot --- .transpire.py | 64 +++++++++++++++++++++++++++++++++++++++++++++++ Dockerfile | 8 ++++++ sopel/default.cfg | 20 +++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 sopel/default.cfg diff --git a/.transpire.py b/.transpire.py index 10fda5b..a1d5876 100644 --- a/.transpire.py +++ b/.transpire.py @@ -6,8 +6,11 @@ name = "ergo" + def images(): yield Image(name="gamja", path=Path("/"), target="gamja") + yield Image(name="sopel", path=Path("/"), target="sopel") + def objects(): version = get_versions(__file__)[name]["version"] @@ -384,6 +387,67 @@ def objects(): }, } + yield { + "apiVersion": "v1", + "kind": "ConfigMap", + "metadata": {"name": "sopel-config"}, + "data": { + "default.cfg": Path(__file__) + .parent.joinpath("sopel", "default.cfg") + .read_text() + }, + } + + sopel_labels = {"k8s.ocf.io/app": name, "k8s.ocf.io/component": "sopel"} + yield { + "apiVersion": "apps/v1", + "kind": "StatefulSet", + "metadata": {"name": "sopel"}, + "spec": { + "replicas": 1, + "serviceName": "sopel", + "selector": {"matchLabels": sopel_labels}, + "template": { + "metadata": {"labels": sopel_labels}, + "spec": { + "containers": [ + { + "name": "sopel", + "image": get_image_tag("sopel"), + # Mount default.cfg to /home/sopel/.sopel/default.cfg + "volumeMounts": [ + { + "name": "sopel-config", + "mountPath": "/home/sopel/.sopel/default.cfg", + "subPath": "default.cfg", + }, + { + "name": "sopel-data", + "mountPath": "/home/sopel/.sopel/", + }, + ], + } + ], + "volumes": [ + { + "name": "sopel-config", + "configMap": {"name": "sopel-config"}, + }, + ], + }, + }, + "volumeClaimTemplates": [ + { + "metadata": {"name": "sopel-data"}, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": {"requests": {"storage": "32Gi"}}, + }, + } + ], + }, + } + yield { "apiVersion": "v1", "kind": "Service", diff --git a/Dockerfile b/Dockerfile index 94927b5..d5ae081 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,3 +11,11 @@ FROM docker.io/caddy:2.7 AS gamja COPY --from=build /gamja /gamja COPY gamja/Caddyfile /etc/caddy/Caddyfile COPY gamja/config.json /gamja/config.json + +FROM docker.io/python:3.11 AS sopel + +RUN adduser --disabled-password --gecos "" --home /home/sopel --uid 1000 sopel +USER sopel +ENV PATH="${PATH}:/home/sopel/.local/bin" +RUN python -m pip install pipx && pipx install git+https://github.com/sopel-irc/sopel.git#ab32aca08f7bf67d1ba754fdfc22a10ee5a442d0 +CMD [ "sopel", "start" ] diff --git a/sopel/default.cfg b/sopel/default.cfg new file mode 100644 index 0000000..25ef27a --- /dev/null +++ b/sopel/default.cfg @@ -0,0 +1,20 @@ +[core] +nick = create +host = irc-dev.ocf.berkeley.edu +use_ssl = true +port = 6697 +owner = njha +channels = "#rebuild,#administrivia,#test" +commands_on_connect = + +[admin] +hold_ground = true +auto_accept_invite = true + +[wikipedia] +default_lang = en + +[help] +output = base +reply_method = channel +line_threshold = 3 \ No newline at end of file