From 7bab68fe31e5bd067a02175333aeaa722c41c9dc Mon Sep 17 00:00:00 2001 From: meliurwen Date: Wed, 22 Dec 2021 16:17:29 +0100 Subject: [PATCH] Added atheme --- atheme/Dockerfile | 58 +++++++++++++++++++++++++++++++++++++++ atheme/root/entrypoint.sh | 34 +++++++++++++++++++++++ docker-compose.yml | 12 ++++++-- solanum/Dockerfile | 15 +++++----- solanum/root/start.sh | 18 ++++++------ 5 files changed, 118 insertions(+), 19 deletions(-) create mode 100644 atheme/Dockerfile create mode 100755 atheme/root/entrypoint.sh diff --git a/atheme/Dockerfile b/atheme/Dockerfile new file mode 100644 index 0000000..ca1abc2 --- /dev/null +++ b/atheme/Dockerfile @@ -0,0 +1,58 @@ +ARG ATHEME_UID=10000 +ARG ATHEME_VERSION=7.2.10-r2 +ARG BUILD_CONTRIB_MODULES= + +FROM alpine:latest AS builder +ARG ATHEME_VERSION +ARG BUILD_CONTRIB_MODULES +ARG MAKE_NUM_JOBS + +# Install build-deps and runtime deps +RUN apk add --no-cache \ + build-base \ + pkgconf \ + openssl-dev \ + git + +# libexecinfo is used by contrib/gen_echoserver +RUN test -z "$BUILD_CONTRIB_MODULES" || apk add --no-cache libexecinfo-dev + +# Checkout from Git - we need to manually bump the libmowgli snapshot to fix compilation against musl +# This will be fixed when 7.3 releases +RUN git clone \ + -b v${ATHEME_VERSION} \ + --depth=1 \ + --recursive \ + https://github.com/atheme/atheme.git /atheme-src + +WORKDIR /atheme-src + +RUN cd libmowgli-2 && \ + git pull origin master + +# Configure and build +RUN ./configure \ + --prefix=/srv/atheme $(test -z "$BUILD_CONTRIB_MODULES" || echo --enable-contrib) && \ + make -j${MAKE_NUM_JOBS:-$(nproc)} && \ + make install + + +FROM alpine:latest +ARG ATHEME_UID +ARG BUILD_CONTRIB_MODULES + +# openssl: used by some hashing and SASL algorithms +# msmtp: used to route mail to an external mail server +RUN apk add --no-cache \ + openssl \ + msmtp \ + ca-certificates \ + && (test -z "$BUILD_CONTRIB_MODULES" || apk add --no-cache libexecinfo) + +RUN adduser -D -u $ATHEME_UID atheme + +COPY --from=builder --chown=atheme /srv/atheme /srv/atheme + +COPY root/ / + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/atheme/root/entrypoint.sh b/atheme/root/entrypoint.sh new file mode 100755 index 0000000..6ea9277 --- /dev/null +++ b/atheme/root/entrypoint.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +DATADIR=/srv/data/etc + +mkdir -p "$DATADIR" + +chown atheme:atheme -R "$DATADIR" + +if [ ! -e $DATADIR/atheme.conf ]; then + echo "Configuration file not found. Generating it..." + cp /srv/atheme/etc/atheme.conf.example $DATADIR/atheme.conf +fi + +if ! test -w "$DATADIR/"; then + echo "ERROR: $DATADIR must be mounted to a directory writable by UID $ATHEME_UID" + exit 1 +fi + +DBPATH="$DATADIR/services.db" +if test -f "$DBPATH" && ! test -r "$DBPATH"; then + echo "ERROR: $DBPATH must be readable by UID $ATHEME_UID" + exit 1 +fi + +TMPPATH="$DATADIR/services.db.new" +if test -f "$TMPPATH" && ! test -w "$TMPPATH"; then + echo "ERROR: $TMPPATH must either not exist or be writable by UID $ATHEME_UID" + exit 1 +fi + +rm -f /srv/atheme/var/atheme.pid +su atheme -c "/srv/atheme/bin/atheme-services \ + -c $DATADIR/atheme.conf \ + -n" diff --git a/docker-compose.yml b/docker-compose.yml index 2b12b73..3c6d684 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,9 +8,7 @@ services: container_name: ${SO_CONTAINER_NAME:-ircd-solanum} restart: ${SO_RESTART:-unless-stopped} volumes: - - ${LOCAL_STACK_DIR}/solanum/etc:/srv/config - - ${LOCAL_STACK_DIR}/solanum/certs:/certs - - ${LOCAL_STACK_DIR}/solanum/logs:/srv/logs + - ${LOCAL_STACK_DIR}/solanum/data:/srv/data ports: - 5000:5000 - 6665-6669:6665-6669 @@ -18,3 +16,11 @@ services: - 9999:9999 environment: - TZ=${TZ} + + atheme: + build: + context: atheme/ + container_name: ${AT_CONTAINER_NAME:-ircd-atheme} + restart: ${AT_RESTART:-unless-stopped} + volumes: + - ${LOCAL_STACK_DIR}/atheme/data:/srv/data diff --git a/solanum/Dockerfile b/solanum/Dockerfile index 2092555..c92cd8c 100644 --- a/solanum/Dockerfile +++ b/solanum/Dockerfile @@ -4,9 +4,11 @@ LABEL maintainer="Meliurwen " RUN apk --update add git -RUN git clone --depth 1 https://github.com/solanum-ircd/solanum.git /solanum +RUN git clone \ + --depth 1 \ + https://github.com/solanum-ircd/solanum.git /solanum-src -WORKDIR /solanum +WORKDIR /solanum-src RUN apk add \ sqlite-dev \ @@ -23,13 +25,12 @@ RUN apk add \ make \ mbedtls-dev RUN ./configure \ - --prefix=/srv/ircd \ + --prefix=/srv/solanum \ --enable-mbedtls RUN apk add \ util-linux -RUN ./configure --prefix=/srv/ircd --enable-mbedtls && \ - make && \ +RUN make -j${MAKE_NUM_JOBS:-$(nproc)} && \ make install @@ -39,9 +40,9 @@ RUN apk add --no-cache \ mbedtls \ libltdl \ sqlite-libs \ - && adduser -D ircd + && adduser -D solanum -COPY --from=builder --chown=ircd /srv/ircd /srv/ircd +COPY --from=builder --chown=solanum /srv/solanum /srv/solanum COPY root/ / diff --git a/solanum/root/start.sh b/solanum/root/start.sh index d345c6c..6751b5d 100755 --- a/solanum/root/start.sh +++ b/solanum/root/start.sh @@ -1,20 +1,20 @@ #!/bin/sh -mkdir -p /srv/config /srv/logs +mkdir -p /srv/data/etc /srv/data/logs -chown ircd:ircd -R /srv/config /srv/logs +chown solanum:solanum -R /srv/data -if [ ! -e /srv/config/ircd.conf ]; then +if [ ! -e /srv/data/etc/ircd.conf ]; then echo "Configuration file not found. Generating it..." - cp /srv/ircd/etc/ircd.conf.example /srv/config/ircd.conf + cp /srv/solanum/etc/ircd.conf.example /srv/data/etc/ircd.conf fi -if [ ! -e /srv/config/ircd.motd ]; then +if [ ! -e /srv/data/etc/ircd.motd ]; then echo "MOTD file not found. Generating it..." - cp /srv/ircd/etc/ircd.motd /srv/config/ircd.motd + cp /srv/solanum/etc/ircd.motd /srv/data/etc/ircd.motd fi -su ircd -c "/srv/ircd/bin/solanum \ - -configfile /srv/config/ircd.conf \ - -logfile /srv/logs/ircd.logs \ +su solanum -c "/srv/solanum/bin/solanum \ + -configfile /srv/data/etc/ircd.conf \ + -logfile /srv/data/logs/ircd.logs \ -foreground"