From 687ddf11a9f7416cc35c3724d6b6a1c5151d50ae Mon Sep 17 00:00:00 2001 From: Millaguie Date: Sat, 13 Apr 2019 19:59:03 +0200 Subject: [PATCH] Docker support --- Dockerfile | 32 ++++++++++++++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++++ entrypoint | 10 ++++++++++ 3 files changed, 68 insertions(+) create mode 100644 Dockerfile create mode 100644 entrypoint diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..14b55f0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM python:3.7-slim-stretch + +RUN apt update && \ + apt install -y git && \ + cd /usr/src/ && \ + git clone https://github.com/n0mjs710/dmr_utils3 && \ + cd /usr/src/dmr_utils3 && \ + ./install.sh && \ + rm -rf /var/lib/apt/lists/* && \ + cd /opt && \ + rm -rf /usr/src/dmr_utils3 && \ + git clone https://github.com/n0mjs710/hblink3 + +RUN cd /opt/hblink3/ && \ + sed -i s/.*python.*//g requirements.txt && \ + pip install --no-cache-dir -r requirements.txt + + +ADD entrypoint /entrypoint + +RUN adduser -u 54000 radio && \ + adduser radio radio && \ + chmod 755 /entrypoint && \ + chown radio:radio /entrypoint && \ + chown radio /opt/hblink3 + +RUN chmod 755 /entrypoint + +USER radio +EXPOSE 54000 + +ENTRYPOINT [ "/entrypoint" ] diff --git a/README.md b/README.md index bb9c0f9..a04b2f4 100755 --- a/README.md +++ b/README.md @@ -24,6 +24,32 @@ None. The owners of this work make absolutely no warranty, express or implied. U **PRE-REQUISITE KNOWLEDGE:** This document assumes the reader is familiar with Linux/UNIX, the Python programming language and DMR. +**Using docker version** + +To use with provided docker configuration you will need: +* A private repository with your configuration files (all .cfg files in repo will be copyed to the application root directory on start) +* A service user able to read your private repository +* A server with docker installed +* Follow this simple steps: + +Build your own image from source + +```bash + +docker build . -t millaguie/hblink:3.0.0 + +``` + +Or user a prebuilt one in docker hub: millaguie/hblink:3.0.0 + +Wake up your container + +```bash +touch /var/log/hblink.log +chown 65000 /var/log/hblink.log + run -v /var/log/hblink.log:/var/log/hblink.log -e GIT_USER=$USER -e GIT_PASSWORD=$PASSWORD -e GIT_REPO=$URL_TO_REPO_WITHOUT_HTTPS:// -p 54000:54000 millaguie/hblink:3.0.0 + ``` + **MORE DOCUMENTATION TO COME** ***0x49 DE N0MJS*** diff --git a/entrypoint b/entrypoint new file mode 100644 index 0000000..84a03e2 --- /dev/null +++ b/entrypoint @@ -0,0 +1,10 @@ +#!/bin/sh + +mkdir -p /var/tmp/config +cd /var/tmp/config +git clone https://${GIT_USER}:${GIT_PASSWORD}@${GIT_REPO} + +DIR=$(echo ${GIT_REPO}| sed s/.git$//g | sed s#^.*/##g) + +cp -a /var/tmp/config/${DIR}/*cfg /opt/hblink3/ +python /opt/hblink3/hblink.py