commit 3fd313f2f5f691354331cd1c15a28b029e33c587 Author: meliurwen Date: Tue Dec 28 14:09:05 2021 +0100 Fully working catbox-ircd stack diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..446f895 --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# Global Settings +LOCAL_STACK_DIR=/srv/docker/volumes/ircd + +# Catbox (optional) +CTB_CONTAINER_NAME= +CTB_RESTART= + +CTB_BLD_REPO= +CTB_BLD_VER= diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..03bd412 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.env diff --git a/catbox/Dockerfile b/catbox/Dockerfile new file mode 100644 index 0000000..f5d8bd9 --- /dev/null +++ b/catbox/Dockerfile @@ -0,0 +1,43 @@ +FROM golang:alpine AS build + +ARG BLD_REPO=${BLD_REPO:-https://github.com/horgh/catbox.git} +ARG BLD_VER=${BLD_VER:-master} + +ARG GOOS +ARG GOARCH + +RUN apk --update add \ + git + +RUN git clone \ + --depth 1 \ + --single-branch \ + --branch ${BLD_VER} \ + ${BLD_REPO} \ + /srv/src/catbox + +WORKDIR /srv/src/catbox + +RUN GOOS=${GOOS} \ + GOARCH=${GOARCH} \ + CGO_ENABLED=0 \ + go build \ + --installsuffix cgo \ + --ldflags "-w -s" \ + -o "/srv/dist/catbox" \ + . + +RUN cp -r /srv/src/catbox/conf /srv/dist/conf && \ + sed -i 's|#opers-config =|opers-config = /srv/data/conf/opers.conf|g' /srv/dist/conf/catbox.conf && \ + sed -i 's|#servers-config =|servers-config = /srv/data/conf/servers.conf|g' /srv/dist/conf/catbox.conf && \ + sed -i 's|#users-config =|users-config = /srv/data/conf/users.conf|g' /srv/dist/conf/catbox.conf + +FROM alpine:latest + +RUN adduser -D catbox + +COPY --from=build --chown=catbox /srv/dist /srv/catbox + +COPY root/ / + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/catbox/root/entrypoint.sh b/catbox/root/entrypoint.sh new file mode 100755 index 0000000..131b4e9 --- /dev/null +++ b/catbox/root/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +mkdir -p /srv/data + +cp --no-clobber -p -r /srv/catbox/conf /srv/data/ + +su catbox \ + -c "/srv/catbox/catbox \ + -conf /srv/data/conf/catbox.conf" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..bd73ab8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" + +services: + catbox: + build: + context: catbox/ + args: + - BLD_REPO=${CTB_BLD_REPO:-https://github.com/horgh/catbox.git} + - BLD_VER=${CTB_BLD_VER:-master} + container_name: ${CTB_CONTAINER_NAME:-ircd-catbox} + restart: ${CTB_RESTART:-unless-stopped} + volumes: + - ${LOCAL_STACK_DIR:-/srv/docker/volumes/ircd}/catbox/data:/srv/data + ports: + - 6667:6667