From 9b7140e65001fa51388897987de1bf1f82f013cb Mon Sep 17 00:00:00 2001 From: Laura Batalha Date: Sat, 3 May 2025 19:18:32 +0100 Subject: [PATCH] add docker instructions and examples --- Dockerfile | 14 ++++++++++++ docker/Dockerfile | 19 ++++++++++++++++ docker/Dockerfile.dist | 21 +++++++++++++++++ docker/README.md | 48 +++++++++++++++++++++++++++++++++++++++ docker/docker-compose.yml | 29 +++++++++++++++++++++++ 5 files changed, 131 insertions(+) create mode 100644 Dockerfile create mode 100644 docker/Dockerfile create mode 100644 docker/Dockerfile.dist create mode 100644 docker/README.md create mode 100644 docker/docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..32da7e0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.13-alpine + +RUN pip --no-cache-dir --disable-pip-version-check --no-input -q install rns + +RUN mkdir /config + +RUN addgroup -S rns --gid 1000 && adduser -S rns --uid 1000 -G rns +RUN chown rns:rns /config + +USER rns:rns + +VOLUME ["/config"] + +ENTRYPOINT ["/usr/local/bin/rnsd", "--config", "/config"] diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..e0f1b24 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.13-alpine + +ENV PIP_ROOT_USER_ACTION=ignore +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 +ENV PIP_NO_CACHE_DIR=1 +RUN pip install rns + +RUN mkdir /config + +RUN addgroup -S rns --gid 1000 && adduser -S rns --uid 1000 -G rns dialout +RUN chown rns:rns /config + +USER rns:rns + +VOLUME ["/config"] + +ENV PYTHONUNBUFFERED=1 + +ENTRYPOINT ["/usr/local/bin/rnsd", "--config", "/config"] diff --git a/docker/Dockerfile.dist b/docker/Dockerfile.dist new file mode 100644 index 0000000..c99d314 --- /dev/null +++ b/docker/Dockerfile.dist @@ -0,0 +1,21 @@ +FROM python:3.13-alpine + +ADD dist/rns-*.whl /tmp/ + +ENV PIP_ROOT_USER_ACTION=ignore +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 +ENV PIP_NO_CACHE_DIR=1 +RUN pip install /tmp/rns-*.whl + +RUN mkdir /config + +RUN addgroup -S rns --gid 1000 && adduser -S rns --uid 1000 -G rns dialout +RUN chown rns:rns /config + +USER rns:rns + +VOLUME ["/config"] + +ENV PYTHONUNBUFFERED=1 + +ENTRYPOINT ["/usr/local/bin/rnsd", "--config", "/config"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..0098c7f --- /dev/null +++ b/docker/README.md @@ -0,0 +1,48 @@ +# Docker Images + +Docker resources Reticulum service and tooling + +## End-user + +As an end-user you can make use of the `Dockerfile` to create a simple docker image based on the latest `rns` package available in [PyPi](https://pypi.org/project/rns/) + +### Building + +To build the image: + +- Copy the `Dockerfile` to a directory and in that directory run: + - `docker build -t reticulum:latest .` + +- From the root of this repository run: + - `docker build -t reticulum:latest -f docker/Dockerfile .` + +### Running + +#### Docker Run +You can run the container in various ways, a quick way to test would be interactively: + +- Create a directory to hold the configuration and other files - `mkdir config` +- Start the container - `docker run --rm --name reticulum -v ./config:/config -it reticulum:latest` + +This will create a container named `reticulum`, mount the config directory to the directory you created above in your current working directory (`./config`) and automatically delete que container (`--rm`) when you detach from the session (files in the config directory will be retained) + +You can edit the config file at `./config/config` to configure rns as usual + +Once the container is running, you can use other rns tools via `docker exec`: + +`docker exec -it reticulum rnpath` + + +#### Docker Compose + +You can also use the included example `docker-compose.yml` file to manage the container in a more automated way. It has some comments but if you are not familiar with it, it is probably a good idea to read the [official `docker compose` docs](https://docs.docker.com/compose/) + + +## Developer + +The file `Dockerfile.dist` is meant to be used for CI, its similar to the end-user Dockerfile except that it will grab and install wheel files from the `/dist` directory instead +This could be used in this order: +- `make build_wheel` +- Build the container with `Dockerfile.dist` + - Via github workflows + - Manually `docker build -t reticulum:latest -f docker/Dockerfile.dist .` diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..410efd2 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,29 @@ +services: + reticulum: + container_name: reticulum + image: reticulum:latest + restart: unless-stopped + # Mount the config directory on the host in the same location as the docker-compose.yml + # to allow data persistency + volumes: + - ./config:/config:rw + # Define ports to expose, for example a TCP Listener + ports: + - "4242:4242/tcp" + networks: + - reticulum + # Define resource limits, useful if more services exist on the same host + # to avoid accidental resource contention, monitor and adjust as needed + deploy: + resources: + limits: + memory: "200M" + +# We define a custom network to allow easy communication between containers, +# for example if you want to run a nomadnet node and make use of the reticulum +# running in this container, you can add nomadnet container to this same network +# and use the service name as the hostname (eg: "reticulum") +# see: https://docs.docker.com/compose/how-tos/networking/#use-a-pre-existing-network +networks: + reticulum: + name: reticulum