-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: docker image for err-aprs-backend (#59)
This adds a Docker file, supporting config file, and CI for building a docker image for running an errbot with the APRS backend.
- Loading branch information
1 parent
22d1c29
commit a82ca42
Showing
7 changed files
with
190 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Runs after release-please creates a new release | ||
# Builds and pushes the docker images for the release | ||
name: Release Docker Images | ||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
build-and-push-dockerimage: | ||
name: Buld and push dockerimage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.THIS_PAT }} | ||
- name: Docker metadata | ||
uses: docker/metadata-action@v4 | ||
id: meta | ||
with: | ||
images: | | ||
${{ github.repository }} | ||
ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=raw,value=${{ github.ref_name }} | ||
# minimal (short sha) | ||
type=sha,prefix= | ||
# full length sha | ||
type=sha,format=long,prefix= | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64 | ||
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Runs after release-please creates a new release | ||
# Builds and pushes the docker images for the release | ||
name: Test building Docker Images | ||
on: | ||
- push | ||
|
||
|
||
jobs: | ||
build-dockerimage: | ||
name: Buld dockerimage | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: false | ||
platforms: linux/amd64,linux/arm64 | ||
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#registry-cache | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,3 +162,5 @@ cython_debug/ | |
.python-version | ||
|
||
test_errbot | ||
|
||
.ruff_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ARG ERRBOT_VERSION=6.2.0 | ||
from python:3.11-slim as builder | ||
|
||
|
||
COPY .github/workflows/constraints.txt /constraints.txt | ||
RUN pip install --upgrade --constraint /constraints.txt pip poetry | ||
COPY ./ /app | ||
WORKDIR /app | ||
RUN poetry build | ||
|
||
from python:3.11-slim | ||
ARG ERRBOT_VERSION=6.2.0 | ||
|
||
COPY --from=builder /app/dist/*.whl / | ||
|
||
RUN pip install --no-cache-dir errbot==$ERRBOT_VERSION err_aprs_backend-*-py3-none-any.whl --force-reinstall && \ | ||
rm -rf /err_aprs_backend-*-py3-none-any.whl && \ | ||
mkdir /errbot && cd /errbot && \ | ||
errbot --init && \ | ||
rm -rf /errbot/plugins/err-example/ | ||
COPY --from=builder /app/docker/config.py /errbot/config.py | ||
|
||
WORKDIR /errbot | ||
ENTRYPOINT [ "errbot" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Docker | ||
|
||
The Docker image for err-aprs-backed is hosted in ghcr.io | ||
|
||
## Environment Variables | ||
|
||
Every [Config option](../CONFIG.md) has a corresponding environment variable. | ||
|
||
Lists and tuples are comma separated strings. | ||
|
||
## Config Choices | ||
|
||
Only ACLS, CommandNotFoundFilter, VersionChecker, and Webserver core plugins are running (this causes an error in the logs on startup, ignore it). | ||
The other core plugins are not optimized for APRS due to either allowing an unauthenticated user to configure the bot, or due to message length. | ||
|
||
SUPPRESS_CMD_NOT_FOUND is set to true, this means the bot will just not respond to messages it doesn't recognize as a command. | ||
|
||
BOT_PREFIX_OPTIONAL_ON_CHAT is set to true, this means that commands can be run with the prefix | ||
|
||
## Plugins | ||
|
||
Plugins can be added to /errbot/plugins or you can reconfigure the directory by setting BOT_PLUGIN_DIR | ||
|
||
## Data | ||
|
||
Data by default is in /errbot/data, but you can mount a volume to store your data permanently and not lose state between container restarts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import logging | ||
import os | ||
import sys | ||
|
||
logger = logging.getLogger(__name__) | ||
# This is a minimal configuration to get you started with the Text mode. | ||
# If you want to connect Errbot to chat services, checkout | ||
# the options in the more complete config-template.py from here: | ||
# https://raw.githubusercontent.com/errbotio/errbot/master/errbot/config-template.py | ||
|
||
BACKEND = "APRS" # Errbot will start in text mode (console only mode) and will answer commands from there. | ||
|
||
BOT_DATA_DIR = os.environ.get("BOT_DATA_DIR", "/errbot/data") | ||
BOT_EXTRA_PLUGIN_DIR = os.environ.get("BOT_PLUGIN_DIR", "/errbot/plugins") | ||
BOT_EXTRA_BACKEND_DIR = os.environ.get("BOT_BACKEND_DIR", "/errbot/backend-plugins") | ||
|
||
BOT_LOG_FILE = None | ||
BOT_LOG_LEVEL = logging.getLevelName(os.environ.get("LOG_LEVEL", "INFO").upper()) | ||
|
||
__callsign = os.environ.get("APRS_CALLSIGN", None) | ||
__password = os.environ.get("APRS_PASSWORD", None) | ||
if __callsign is None: | ||
logger.fatal("APRS_CALLSIGN environment variable is not set") | ||
sys.exit(1) | ||
if __password is None: | ||
logger.fatal("APRS_PASSWORD environment variable is not set") | ||
sys.exit(1) | ||
|
||
BOT_ADMINS = __callsign | ||
|
||
BOT_IDENTITY = {"callsign": __callsign, "password": __password} | ||
|
||
APRS_FROM_CALLSIGN = os.environ.get("APRS_FROM_CALLSIGN", __callsign) | ||
APRS_LISTENED_CALLSIGNS = tuple(os.environ.get("APRS_LISTENED_CALLSIGNS", "").strip(",").split(",")) | ||
APRS_HELP_TEXT = os.environ.get("APRS_HELP_TEXT", "APRSBot,Errbot & err-aprs-backend") | ||
APRS_MAX_DROPPED_PACKETS = os.environ.get("APRS_MAX_DROPPED_PACKETS", "25") | ||
APRS_MAX_CACHED_PACKETS = os.environ.get("APRS_MAX_CACHED_PACKETS", "2048") | ||
APRS_MAX_AGE_CACHED_PACETS_SECONDS = os.environ.get("APRS_MAX_AGE_CACHED_PACETS_SECONDS", "3600") | ||
APRS_MESSAGE_MAX_RETRIES = os.environ.get("APRS_MESSAGE_MAX_RETRIES", "7") | ||
APRS_MESSAGE_RETRY_WAIT = os.environ.get("APRS_MESSAGE_RETRY_WAIT", "90") | ||
APRS_STRIP_NEWLINES = os.environ.get("APRS_STRIP_NEWLINES", "true") | ||
APRS_LANGUAGE_FILTER = os.environ.get("APRS_LANGUAGE_FILTER", "true") | ||
APRS_LANGUAGE_FILTER_EXTRA_WORDS = os.environ.get("APRS_LANGUAGE_FILTER_EXTRA_WORDS", "").strip(",").split(",") | ||
APRS_REGISTRY_ENABLED = os.environ.get("APRS_REGISTRY_ENABLED", "false").lower() | ||
APRS_REGISTRY_URL = os.environ.get("APRS_REGISTRY_URL", "https://aprs.hemna.com/api/v1/registry") | ||
APRS_REGISTRY_FREQUENCY_SECONDS = os.environ.get("APRS_REGISTRY_FREQUENCY_SECONDS", "3600") | ||
APRS_REGISTRY_DESCRIPTION = os.environ.get("APRS_REGISTRY_DESCRIPTION", "err-aprs-backend powered bot") | ||
APRS_REGISTRY_WEBSTIRE = os.environ.get("APRS_REGISTRY_WEBSTIRE", "") | ||
|
||
BOT_PREFIX = os.environ.get("BOT_PREFIX", "!") | ||
BOT_PREFIX_OPTIONAL_ON_CHAT = True | ||
SUPPRESS_CMD_NOT_FOUND = True | ||
|
||
# core plugins are not APRS optimized, only load ones that work | ||
# this causes some erros in the logs | ||
CORE_PLUGINS = ( | ||
"ACLs", | ||
"CommandNotFoundFilter", | ||
"VersionChecker", | ||
"Webserver", | ||
) |