From a7aab49a90339c9d530859aa993b2de530fec31b Mon Sep 17 00:00:00 2001 From: Andre lorbach Date: Mon, 22 Jan 2024 13:11:10 +0100 Subject: [PATCH] Add Dockerfiles for new doc generation container (base/buildbot) - based on ubuntu 22.04 LTS closes: https://github.com/rsyslog/rsyslog-docker/issues/59 --- dev_env/ubuntu/doc_base/22.04/Dockerfile | 28 +++++++++++++ dev_env/ubuntu/doc_base/22.04/build.sh | 5 +++ dev_env/ubuntu/doc_base/22.04/run.sh | 21 ++++++++++ dev_env/ubuntu/doc_buildbot/22.04/Dockerfile | 20 ++++++++++ dev_env/ubuntu/doc_buildbot/22.04/build.sh | 1 + .../doc_buildbot/22.04/tpl-buildbot.tac | 39 +++++++++++++++++++ 6 files changed, 114 insertions(+) create mode 100644 dev_env/ubuntu/doc_base/22.04/Dockerfile create mode 100755 dev_env/ubuntu/doc_base/22.04/build.sh create mode 100755 dev_env/ubuntu/doc_base/22.04/run.sh create mode 100644 dev_env/ubuntu/doc_buildbot/22.04/Dockerfile create mode 100755 dev_env/ubuntu/doc_buildbot/22.04/build.sh create mode 100644 dev_env/ubuntu/doc_buildbot/22.04/tpl-buildbot.tac diff --git a/dev_env/ubuntu/doc_base/22.04/Dockerfile b/dev_env/ubuntu/doc_base/22.04/Dockerfile new file mode 100644 index 0000000..f2c4808 --- /dev/null +++ b/dev_env/ubuntu/doc_base/22.04/Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:22.04 +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && \ + apt-get upgrade -y +RUN apt-get install -y \ + autoconf \ + autoconf-archive \ + automake \ + autotools-dev \ + net-tools \ + bison \ + curl \ + flex \ + git \ + sudo \ + vim \ + wget \ + python3-docutils \ + python3-pip \ + python3-pysnmp4 +RUN pip install sphinx sphinx_rtd_theme +VOLUME /rsyslog +RUN groupadd rsyslog \ + && useradd -g rsyslog -s /bin/bash rsyslog \ + && echo "rsyslog ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \ + && echo "buildbot ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +WORKDIR /rsyslog +USER rsyslog diff --git a/dev_env/ubuntu/doc_base/22.04/build.sh b/dev_env/ubuntu/doc_base/22.04/build.sh new file mode 100755 index 0000000..91924d8 --- /dev/null +++ b/dev_env/ubuntu/doc_base/22.04/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +# Use --no-cache to rebuild image +docker build $1 -t rsyslog/rsyslog_dev_doc_base_ubuntu:22.04 . +printf "\n\n================== BUILD DONE\n" diff --git a/dev_env/ubuntu/doc_base/22.04/run.sh b/dev_env/ubuntu/doc_base/22.04/run.sh new file mode 100755 index 0000000..4623eed --- /dev/null +++ b/dev_env/ubuntu/doc_base/22.04/run.sh @@ -0,0 +1,21 @@ +#!/bin/bash +printf "\n\n================== ENTER DOCKER CONTAINER\n" + +if [ "$RSYSLOG_HOME" == "" ]; then + export RSYSLOG_HOME=$(pwd) + echo info: RSYSLOG_HOME not set, using $RSYSLOG_HOME +fi + +printf 'user ids: %s:%s\n' $(id -u) $(id -g) +printf 'container_uid: %s\n' ${RSYSLOG_CONTAINER_UID--u $(id -u):$(id -g)} +printf 'container cmd: %s\n' $* + +# Run docker +docker run \ + --privileged \ + --cap-add=SYS_ADMIN \ + -e ENVTODO \ + ${RSYSLOG_CONTAINER_UID--u $(id -u):$(id -g)} \ + $DOCKER_RUN_EXTRA_FLAGS \ + -v "$RSYSLOG_HOME":/rsyslog \ + -ti --rm rsyslog/rsyslog_dev_doc_base_ubuntu:22.04 diff --git a/dev_env/ubuntu/doc_buildbot/22.04/Dockerfile b/dev_env/ubuntu/doc_buildbot/22.04/Dockerfile new file mode 100644 index 0000000..7f91f8f --- /dev/null +++ b/dev_env/ubuntu/doc_buildbot/22.04/Dockerfile @@ -0,0 +1,20 @@ +FROM rsyslog/rsyslog_dev_doc_base_ubuntu:22.04 +USER root +RUN apt-get update && apt-get install -y \ + python3-dev \ + python3-pip +RUN pip3 install buildbot-worker buildbot-slave +RUN groupadd -r buildbot && useradd -r -g buildbot buildbot +RUN mkdir /worker && chown buildbot:buildbot /worker +# Install your build-dependencies here ... +ENV WORKER_ENVIRONMENT_BLACKLIST=WORKER* +USER buildbot +WORKDIR /worker +RUN buildbot-worker create-worker . docker.rsyslog.com docker-ubuntu16 password +# the following script is directly from buildbot git repo and seems +# to be necessary at the moment. +# see https://github.com/buildbot/buildbot/issues/4179 +COPY tpl-buildbot.tac /worker/buildbot.tac +ENTRYPOINT ["/usr/local/bin/buildbot-worker"] +CMD ["start", "--nodaemon"] +VOLUME /worker diff --git a/dev_env/ubuntu/doc_buildbot/22.04/build.sh b/dev_env/ubuntu/doc_buildbot/22.04/build.sh new file mode 100755 index 0000000..9fcc721 --- /dev/null +++ b/dev_env/ubuntu/doc_buildbot/22.04/build.sh @@ -0,0 +1 @@ +docker build $1 -t rsyslog/rsyslog_dev_doc_buildbot_ubuntu:22.04 . diff --git a/dev_env/ubuntu/doc_buildbot/22.04/tpl-buildbot.tac b/dev_env/ubuntu/doc_buildbot/22.04/tpl-buildbot.tac new file mode 100644 index 0000000..5a3ff89 --- /dev/null +++ b/dev_env/ubuntu/doc_buildbot/22.04/tpl-buildbot.tac @@ -0,0 +1,39 @@ +import fnmatch +import os +import sys + +from twisted.application import service +from twisted.python.log import FileLogObserver +from twisted.python.log import ILogObserver + +from buildbot_worker.bot import Worker + +# setup worker +basedir = os.path.abspath(os.path.dirname(__file__)) +application = service.Application('buildbot-worker') + + +application.setComponent(ILogObserver, FileLogObserver(sys.stdout).emit) +# and worker on the same process! +buildmaster_host = os.environ.get("BUILDMASTER", 'localhost') +port = int(os.environ.get("BUILDMASTER_PORT", 9989)) +workername = os.environ.get("WORKERNAME", 'docker') +passwd = os.environ.get("WORKERPASS") + +# delete the password from the environ so that it is not leaked in the log +blacklist = os.environ.get("WORKER_ENVIRONMENT_BLACKLIST", "WORKERPASS").split() +for name in list(os.environ.keys()): + for toremove in blacklist: + if fnmatch.fnmatch(name, toremove): + del os.environ[name] + +keepalive = 600 +umask = None +maxdelay = 300 +allow_shutdown = None +maxretries = 10 + +s = Worker(buildmaster_host, port, workername, passwd, basedir, + keepalive, umask=umask, maxdelay=maxdelay, + allow_shutdown=allow_shutdown, maxRetries=maxretries) +s.setServiceParent(application)