From 1852f1aa2d1b54de26d4632fe461a87872adf2e2 Mon Sep 17 00:00:00 2001 From: Benoit Donneaux Date: Mon, 27 May 2024 16:12:30 +0200 Subject: [PATCH] Add docker support for Trac and Gitea Signed-off-by: Benoit Donneaux --- docker-compose.yml | 60 +++++++++++++++++++++++++++++++++ docker/gitea/Dockerfile | 6 ++++ docker/trac/Dockerfile | 65 ++++++++++++++++++++++++++++++++++++ docker/trac/requirements.txt | 13 ++++++++ gitea/.gitkeep | 0 trac/.gitkeep | 0 6 files changed, 144 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/gitea/Dockerfile create mode 100644 docker/trac/Dockerfile create mode 100644 docker/trac/requirements.txt create mode 100644 gitea/.gitkeep create mode 100644 trac/.gitkeep diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..aa47d0f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,60 @@ +# Docker compose file to support dev+ops activities +version: '3' +services: + trac: + build: + context: docker/trac + dockerfile: Dockerfile + args: + user: appuser + group: appgroup + uid: "${_UID:-1000}" + gid: "${_GID:-1000}" + volumes: + - ./trac:/var/lib/appdata + - ./trac/public_html:/trac/chrome + - ./trac/repos:/home/sources/git + working_dir: /var/lib/appdata + stdin_open: true + tty: true + hostname: trac.local + container_name: trac.local + ports: + - "${TRAC_PORT:-8000}:${TRAC_PORT:-8000}/tcp" + #command: /bin/bash + command: tracd --port ${TRAC_PORT:-8000} --auth="Tahoe-LAFS,./Tahoe-LAFS/conf/user_passwd,tahoe-lafs.org" ./Tahoe-LAFS + network_mode: "bridge" + # Prevents container to hang the host + # Requires `... --compatibility run ...` + deploy: + resources: + limits: + cpus: '1.5' + memory: 256M + + gitea: + build: + context: docker/gitea + dockerfile: Dockerfile + volumes: + - ./gitea/conf:/etc/gitea + - ./gitea/data:/var/lib/gitea + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + working_dir: /var/lib/appdata + ports: + - "3000:3000" + - "2222:2222" + #command: /bin/bash + stdin_open: true + tty: true + hostname: gitea.local + container_name: gitea.local + network_mode: "bridge" + # Prevents container to hang the host + # Requires `... --compatibility run ...` + deploy: + resources: + limits: + cpus: '1.5' + memory: 256M diff --git a/docker/gitea/Dockerfile b/docker/gitea/Dockerfile new file mode 100644 index 0000000..b4540a3 --- /dev/null +++ b/docker/gitea/Dockerfile @@ -0,0 +1,6 @@ +############################## +# General level requirements # +############################## + +# Pull official base image from DockerHub +FROM gitea/gitea:1.21.7-rootless@sha256:5d433ef2ebae7eae7b0d0ec42263645a9d200d342fc31ea5bca9745611f89811 diff --git a/docker/trac/Dockerfile b/docker/trac/Dockerfile new file mode 100644 index 0000000..1bf4b70 --- /dev/null +++ b/docker/trac/Dockerfile @@ -0,0 +1,65 @@ +############################## +# General level requirements # +############################## + +# Pull official base image from DockerHub +FROM python:2.7.18-slim-buster@sha256:6c1ffdff499e29ea663e6e67c9b6b9a3b401d554d2c9f061f9a45344e3992363 + +# Avoid interactive frontend +ENV DEBIAN_FRONTEND="noninteractive" + +################################## +# Application level requirements # +################################## +# Install required packages +RUN INSTALL_PKGS="git" && \ + apt-get -q clean && \ + apt-get -q update && \ + apt-get install -y $INSTALL_PKGS && \ + apt-get -q clean + +########################### +# User level requirements # +########################### + +# Parameters for default user:group +ARG uid=1000 +ARG user=appuser +ARG gid=1000 +ARG group=appgroup + +# Add user and group for build and runtime +# So the output can be owned by the specified uid:gid +RUN grep -q ":${gid}:" /etc/group && { \ + echo "Group ID ${gid} found"; \ + } || { \ + echo "Group ID ${gid} NOT found"; \ + groupadd -g "${gid}" "${group}" && \ + echo "Group ID ${gid} created"; \ + } +RUN id "${uid}" > /dev/null 2>&1 && { \ + echo "User ID ${uid} found"; \ + } || { \ + echo "User ID ${uid} NOT found"; \ + useradd -md "/home/${user}" -s /bin/bash -g "${group}" -u "${uid}" "${user}" && \ + echo "User ID ${uid} created"; \ + } + +# Switch to non-root user +USER ${user} +WORKDIR /home/${user} + +# Prepare user variables +ENV USER ${user} +ENV HOME=/home/${user} +ENV PATH="${HOME}/.local/bin:${PATH}" +ENV PYTHONPATH="." + +# Upgrade Pip +RUN python -m pip install --disable-pip-version-check --no-cache --upgrade "pip==20.3.4" + +# Copy requirements +COPY requirements.txt /home/${user}/requirements.txt + +# Install requirements +RUN python -m pip install --user --no-cache --upgrade -r requirements.txt diff --git a/docker/trac/requirements.txt b/docker/trac/requirements.txt new file mode 100644 index 0000000..926cea4 --- /dev/null +++ b/docker/trac/requirements.txt @@ -0,0 +1,13 @@ +Babel==2.9.1 +docutils==0.18.1 +Genshi==0.7.7 +html5lib==1.1 +Pygments==2.5.2 +pytz==2024.1 +six==1.16.0 +textile==3.0.4 +Trac==1.0.13 +TracAccountManager==0.6.0 +TracHTTPAuth==1.2 +TracXMLRPC==1.1.9 +webencodings==0.5.1 diff --git a/gitea/.gitkeep b/gitea/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/trac/.gitkeep b/trac/.gitkeep new file mode 100644 index 0000000..e69de29