13 Commits
0.2.0 ... 0.2.2

13 changed files with 105 additions and 8 deletions

View File

@@ -0,0 +1,20 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Development",
"image": "mcr.microsoft.com/devcontainers/python:1-3.13-bookworm",
"features": {
"ghcr.io/eitsupi/devcontainer-features/go-task:1": {},
"ghcr.io/jsburckhardt/devcontainer-features/uv:1": {}
},
"forwardPorts": [
5000
],
"portsAttributes": {
"5000": {
"label": "Application",
"protocol": "http",
"public": true
}
}
}

View File

@@ -31,6 +31,7 @@ jobs:
uses: docker/build-push-action@v6
with:
push: true
platforms: linux/amd64,linux/arm64
build-args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
tags: |

View File

@@ -13,7 +13,7 @@ jobs:
matrix:
python-version: ["3.13"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Install Task
uses: arduino/setup-task@v2
with:

View File

@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Setup Python
uses: actions/setup-python@v5

View File

@@ -15,6 +15,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
FROM python:${PYTHON_VERSION}-slim-bookworm
COPY --from=builder --chown=app:app /app /app
COPY ./docs/examples/config-basic.ini /app/config.ini
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 80/tcp
EXPOSE 5000/tcp
WORKDIR /app
CMD ["smsbot"]

View File

@@ -1,5 +1,10 @@
version: 3
tasks:
default:
deps:
- python:tests
- python:lint
python:tests:
desc: Run Python tests
cmds:

5
docs/examples/README.md Normal file
View File

@@ -0,0 +1,5 @@
# Example deployments
Examples of how to deploy SMSBot.
* [Flux HelmRelease](flux-helmrelease.yaml) - An example Flux `HelmRelease` using a common chart for basic deployment.

View File

@@ -0,0 +1,2 @@
[logging]
level = INFO

View File

@@ -13,3 +13,4 @@ bot_token = BOT_TOKEN
[twilio]
account_sid = TWILIO_ACCOUNT_SID
auth_token = TWILIO_AUTH_TOKEN
from_number = +12345678901

View File

@@ -0,0 +1,55 @@
---
# yaml-language-server: $schema=https://nikdoof.github.io/flux-gitops/schemas/source.toolkit.fluxcd.io/helmrepository_v1.json
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: nikdoof
namespace: flux-system
spec:
interval: 4h
url: https://nikdoof.github.io/helm-charts/
---
# yaml-language-server: $schema=https://nikdoof.github.io/flux-gitops/schemas/helm.toolkit.fluxcd.io/helmrelease_v2.json
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: smsbot
spec:
interval: 12h
chart:
spec:
chart: common-chart
version: 1.2.3
sourceRef:
kind: HelmRepository
name: nikdoof
namespace: flux-system
interval: 12h
values:
global:
nameOverride: smsbot
image:
repository: ghcr.io/nikdoof/smsbot
tag: 0.2.0
imagePullPolicy: IfNotPresent
controller:
strategy: Recreate
annotations:
secret.reloader.stakater.com/reload: "smsbot-secrets"
envFrom:
- secretRef:
name: smsbot-secrets
service:
main:
ports:
http:
port: 5000
ingress:
main:
enabled: true
hosts:
- host: smsbot-webhooks.example.com
paths:
- path: /
pathType: Prefix

View File

@@ -1,6 +1,6 @@
[project]
name = "smsbot"
version = "0.2.0"
version = "0.2.2"
description = "A simple Telegram bot to receive SMS messages."
authors = [{ name = "Andrew Williams", email = "andy@tensixtyone.com" }]
license = { text = "MIT" }

View File

@@ -15,6 +15,10 @@ from smsbot.utils import get_smsbot_version
from smsbot.webhook import TwilioWebhookHandler
# Prefix of the environment variables to override config values
ENVIRONMENT_PREFIX = "SMSBOT_"
def main():
parser = argparse.ArgumentParser("smsbot")
parser.add_argument(
@@ -44,9 +48,11 @@ def main():
# Override with environment variables, named SMSBOT_<SECTION>_<VALUE>
for key, value in os.environ.items():
if key.startswith("SMSBOT_"):
logging.debug("Overriding config %s with value %s", key, value)
section, option = key[7:].split("_", 1)
if key.startswith(ENVIRONMENT_PREFIX):
section, option = key[7:].lower().split("_", 1)
logging.debug("Overriding config %s/%s = %s", section, option, value)
if not config.has_section(section):
config.add_section(section)
config[section][option] = value
# Validate configuration

2
uv.lock generated
View File

@@ -592,7 +592,7 @@ wheels = [
[[package]]
name = "smsbot"
version = "0.2.0"
version = "0.2.2"
source = { editable = "." }
dependencies = [
{ name = "flask", extra = ["async"] },