Skip to content

Commit

Permalink
🚀 deploy irc bot
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiljha committed Apr 22, 2024
1 parent abe5212 commit d6ffc1b
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .transpire.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
20 changes: 20 additions & 0 deletions sopel/default.cfg
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d6ffc1b

Please sign in to comment.