mirror of
https://github.com/nikdoof/smsbot.git
synced 2025-12-13 10:02:15 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d00a4048cd
|
|||
|
bb5472f092
|
|||
|
6ce86042fb
|
|||
|
0a2970c38f
|
|||
|
126713c84a
|
|||
|
bace0200ab
|
|||
|
e98b8e6b8c
|
|||
| 876b0363c0 | |||
|
d0c18a1d00
|
|||
|
b056d6328d
|
|||
|
40a263686d
|
|||
|
5f1e5508f0
|
|||
|
|
6f36caf6e1 |
20
.devcontainer/devcontainer.json
Normal file
20
.devcontainer/devcontainer.json
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
1
.github/workflows/build-container.yaml
vendored
1
.github/workflows/build-container.yaml
vendored
@@ -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: |
|
||||
|
||||
2
.github/workflows/lint.yaml
vendored
2
.github/workflows/lint.yaml
vendored
@@ -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:
|
||||
|
||||
2
.github/workflows/release.yaml
vendored
2
.github/workflows/release.yaml
vendored
@@ -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
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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
5
docs/examples/README.md
Normal 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.
|
||||
2
docs/examples/config-basic.ini
Normal file
2
docs/examples/config-basic.ini
Normal file
@@ -0,0 +1,2 @@
|
||||
[logging]
|
||||
level = INFO
|
||||
@@ -13,3 +13,4 @@ bot_token = BOT_TOKEN
|
||||
[twilio]
|
||||
account_sid = TWILIO_ACCOUNT_SID
|
||||
auth_token = TWILIO_AUTH_TOKEN
|
||||
from_number = +12345678901
|
||||
55
docs/examples/flux-helmrelease.yaml
Normal file
55
docs/examples/flux-helmrelease.yaml
Normal 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
|
||||
|
||||
@@ -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" }
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user