Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit 457bbb1

Browse files
committed
feat(docker): enhance Docker setup for UnrealIRCd and Atheme services
- Added a comprehensive .dockerignore file to exclude unnecessary files from the Docker build context. - Updated docker-compose.yml to define services for ircd, atheme, and webpanel with optimized configurations and health checks. - Refined Dockerfile to use a stable base image, implement multi-stage builds, and improve security and performance with non-root users and optimized build flags. - Introduced README.md to document the Docker setup, including build instructions, service management, and configuration details.
1 parent 9a704c2 commit 457bbb1

File tree

4 files changed

+818
-38
lines changed

4 files changed

+818
-38
lines changed

.dockerignore

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Git and version control
2+
.git
3+
.gitignore
4+
.gitattributes
5+
6+
# Documentation
7+
docs/
8+
*.md
9+
README*
10+
11+
# Docker files
12+
docker-compose.yml
13+
Dockerfile*
14+
.dockerignore
15+
16+
# Development and CI files
17+
scripts/
18+
renovate.json
19+
.github/
20+
.vscode/
21+
.idea/
22+
23+
# Logs and temporary files
24+
*.log
25+
*.tmp
26+
*.temp
27+
logs/
28+
tmp/
29+
temp/
30+
31+
# OS generated files
32+
.DS_Store
33+
.DS_Store?
34+
._*
35+
.Spotlight-V100
36+
.Trashes
37+
ehthumbs.db
38+
Thumbs.db
39+
40+
# Node.js (if any web components)
41+
node_modules/
42+
npm-debug.log*
43+
yarn-debug.log*
44+
yarn-error.log*
45+
46+
# Python (if any)
47+
__pycache__/
48+
*.py[cod]
49+
*$py.class
50+
*.so
51+
.Python
52+
env/
53+
venv/
54+
.venv/
55+
pip-log.txt
56+
pip-delete-this-directory.txt
57+
58+
# IDE and editor files
59+
.vscode/
60+
.idea/
61+
*.swp
62+
*.swo
63+
*~
64+
65+
# Backup files
66+
*.bak
67+
*.backup
68+
*.old
69+
70+
# Test files
71+
test/
72+
tests/
73+
*_test.py
74+
*.test.js
75+
*.spec.js
76+
77+
# Configuration files that might contain secrets
78+
.env*
79+
*.env
80+
config.local.*

Dockerfile

Lines changed: 144 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,181 @@
1-
FROM debian:unstable-20250811-slim AS base
1+
# Use a more specific and stable base image
2+
FROM debian:bookworm-slim AS base
23

4+
# Add metadata labels
5+
LABEL maintainer="AllThingsLinux IRC Infrastructure" \
6+
description="Optimized IRC services with UnrealIRCd and Atheme" \
7+
version="1.0.0" \
8+
org.opencontainers.image.source="https://github.com/allthingslinux/irc.atl.chat"
39

10+
# Set environment variables for non-interactive package installation
411
ENV DEBIAN_FRONTEND=noninteractive \
5-
DEBCONF_NONINTERACTIVE_SEEN=true
12+
DEBCONF_NONINTERACTIVE_SEEN=true \
13+
# Set build arguments as environment variables for better caching
14+
UNREALIRCD_VERSION="6.1.10" \
15+
ATHEME_VERSION="7.2.12"
616

17+
# Install system dependencies in a single layer with cleanup
718
RUN apt-get update && \
819
apt-get upgrade -y && \
9-
apt-get install -y \
10-
build-essential \
11-
gdb \
12-
gettext \
13-
libargon2-dev \
14-
libc-ares-dev \
15-
libcurl4-openssl-dev \
16-
libpcre2-dev \
17-
libssl-dev \
18-
libsodium-dev \
19-
pkg-config \
20-
wget && \
20+
apt-get install -y --no-install-recommends \
21+
build-essential=12.9 \
22+
gdb=13.1-3 \
23+
gettext=0.21-12 \
24+
libargon2-dev=0~20171227-0.3+deb12u1 \
25+
libc-ares-dev=1.18.1-3 \
26+
libcurl4-openssl-dev=7.88.1-10+deb12u12 \
27+
libpcre2-dev=10.42-1 \
28+
libssl-dev=3.0.17-1~deb12u2 \
29+
libsodium-dev=1.0.18-1 \
30+
pkg-config=1.8.1-1 \
31+
wget=1.21.3-1+deb12u1 \
32+
ca-certificates=20230311+deb12u1 \
33+
git=1:2.39.2-1.1 \
34+
# Additional Atheme dependencies for better functionality
35+
libidn2-dev=2.3.3-1+b1 \
36+
nettle-dev=3.8.1-2 \
37+
libqrencode-dev=4.1.1-1 \
38+
# Development tools for better builds
39+
autoconf=2.71-3 \
40+
automake=1:1.16.5-1.3 \
41+
libtool=2.4.7-7~deb12u1 && \
2142
apt-get clean && \
22-
rm -rf /var/cache/apt/archives/* && \
23-
rm -rf /var/lib/apt/lists/*
43+
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /tmp/* /var/tmp/*
2444

45+
# Builder stage for compiling UnrealIRCd and Atheme
2546
FROM base AS builder
2647

48+
# Create non-root user for building
2749
RUN groupadd --system --gid 1001 builder && \
2850
useradd --create-home --system --uid 1001 --gid builder builder
2951

30-
ARG UNREALIRCD_VERSION="6.1.10"
31-
ARG ATHEME_VERSION="7.2.12"
32-
33-
ENV UNREALIRCD_BASENAME="unrealircd-${UNREALIRCD_VERSION}"
34-
ENV ATHEME_BASENAME="atheme-services-v${ATHEME_VERSION}"
35-
52+
# Set build arguments
53+
ARG UNREALIRCD_VERSION
54+
ARG ATHEME_VERSION
55+
56+
# Set environment variables for the build
57+
ENV UNREALIRCD_BASENAME="unrealircd-${UNREALIRCD_VERSION}" \
58+
ATHEME_BASENAME="atheme-services-v${ATHEME_VERSION}" \
59+
# Compiler optimization flags
60+
CFLAGS="-O2 -march=native -mtune=native -fstack-protector-strong -D_FORTIFY_SOURCE=2" \
61+
CXXFLAGS="-O2 -march=native -mtune=native -fstack-protector-strong -D_FORTIFY_SOURCE=2" \
62+
LDFLAGS="-Wl,-z,relro,-z,now" \
63+
# Build optimization
64+
MAKEFLAGS="-j$(nproc)" \
65+
# Atheme-specific build flags
66+
ATHEME_CFLAGS="-O2 -march=native -mtune=native" \
67+
ATHEME_LDFLAGS="-Wl,-z,relro,-z,now"
68+
69+
# Create necessary directories
3670
RUN mkdir -p /usr/src/unrealircd /usr/src/atheme /usr/local/unrealircd /usr/local/atheme
71+
72+
# Download and extract UnrealIRCd (with better error handling)
3773
WORKDIR /usr/src/unrealircd
38-
RUN wget --quiet https://www.unrealircd.org/downloads/${UNREALIRCD_BASENAME}.tar.gz && \
39-
tar xvf "$UNREALIRCD_BASENAME".tar.gz && \
74+
RUN wget --quiet --show-progress --timeout=30 --tries=3 \
75+
"https://www.unrealircd.org/downloads/${UNREALIRCD_BASENAME}.tar.gz" && \
76+
tar xf "${UNREALIRCD_BASENAME}.tar.gz" && \
77+
rm "${UNREALIRCD_BASENAME}.tar.gz" && \
4078
chown -R builder:builder /usr/src/unrealircd /usr/local/unrealircd
4179

80+
# Download and extract Atheme (with better error handling)
4281
WORKDIR /usr/src/atheme
43-
RUN wget --quiet https://github.com/atheme/atheme/releases/download/v${ATHEME_VERSION}/${ATHEME_BASENAME}.tar.xz && \
44-
tar xvf "$ATHEME_BASENAME".tar.xz && \
82+
RUN wget --quiet --show-progress --timeout=30 --tries=3 \
83+
"https://github.com/atheme/atheme/releases/download/v${ATHEME_VERSION}/${ATHEME_BASENAME}.tar.xz" && \
84+
tar xf "${ATHEME_BASENAME}.tar.xz" && \
85+
rm "${ATHEME_BASENAME}.tar.xz" && \
4586
chown -R builder:builder /usr/src/atheme /usr/local/atheme
4687

88+
# Ensure proper ownership
4789
RUN chown builder:builder /usr/local/unrealircd
4890

91+
# Switch to builder user
4992
USER builder:builder
5093

51-
WORKDIR /usr/src/unrealircd/"$UNREALIRCD_BASENAME"
52-
COPY ./unrealircd/config.settings .
94+
# Build UnrealIRCd
95+
WORKDIR "/usr/src/unrealircd/${UNREALIRCD_BASENAME}"
96+
COPY --chown=builder:builder ./unrealircd/config.settings .
5397
RUN ./Config -quick && \
54-
make && \
98+
make -j"$(nproc)" && \
5599
make install && \
56100
make clean
57101

58-
WORKDIR /usr/src/atheme/"$ATHEME_BASENAME"
59-
RUN ./configure --prefix=/usr/local/atheme && \
60-
make && \
102+
# Set up UnrealIRCd contrib modules repository
103+
WORKDIR /usr/local/unrealircd
104+
RUN git clone --depth 1 https://github.com/unrealircd/unrealircd-contrib.git contrib && \
105+
chown -R builder:builder contrib
106+
107+
# Build Atheme with optimized configuration
108+
WORKDIR "/usr/src/atheme/${ATHEME_BASENAME}"
109+
RUN ./configure \
110+
--prefix=/usr/local/atheme \
111+
--enable-compiler-sanitizers \
112+
--disable-heap-allocator \
113+
--disable-linker-defs \
114+
--enable-fhs-paths \
115+
--enable-large-net \
116+
--enable-contrib \
117+
--enable-nls \
118+
--enable-reproducible-builds \
119+
--with-perl \
120+
--with-pkg-config && \
121+
make -j"$(nproc)" && \
61122
make install && \
62123
make clean
63124

64-
FROM base AS dev
125+
# Final runtime stage
126+
FROM base AS runtime
65127

128+
# Create runtime user
66129
RUN groupadd --system --gid 1001 ircd && \
67130
useradd --system --uid 1001 --gid ircd ircd
68131

69-
RUN mkdir -p /usr/local
132+
# Create necessary directories
133+
RUN mkdir -p /usr/local /var/log /var/run
134+
135+
# Copy compiled binaries from builder stage
70136
COPY --from=builder --chown=ircd:ircd /usr/local/atheme /usr/local/atheme
71137
COPY --from=builder --chown=ircd:ircd /usr/local/unrealircd /usr/local/unrealircd
138+
139+
# Copy startup script
140+
COPY --chown=ircd:ircd scripts/start-services.sh /usr/local/bin/start-services
141+
142+
# Copy module management scripts
143+
COPY --chown=ircd:ircd scripts/manage-modules.sh /usr/local/bin/manage-modules
144+
COPY --chown=ircd:ircd scripts/module-config.sh /usr/local/bin/module-config
145+
146+
# Set proper permissions and create necessary symlinks
147+
RUN chmod 755 /usr/local/atheme/bin/* /usr/local/unrealircd/bin/* && \
148+
chown -R ircd:ircd /var/log /var/run && \
149+
# Create symlinks for easier access
150+
ln -sf /usr/local/atheme/bin/atheme-services /usr/local/bin/atheme-services && \
151+
ln -sf /usr/local/unrealircd/bin/unrealircd /usr/local/bin/unrealircd && \
152+
# Ensure proper ownership of configuration directories
153+
mkdir -p /usr/local/atheme/etc /usr/local/unrealircd/conf && \
154+
chown -R ircd:ircd /usr/local/atheme/etc /usr/local/unrealircd/conf && \
155+
# Create Atheme database directory
156+
mkdir -p /usr/local/atheme/var && \
157+
chown -R ircd:ircd /usr/local/atheme/var
158+
159+
# Switch to runtime user
160+
USER ircd:ircd
161+
162+
# Set working directory
163+
WORKDIR /usr/local/unrealircd
164+
165+
# Expose default IRC ports
166+
EXPOSE 6667 6697
167+
168+
# Health check for both services
169+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
170+
CMD pgrep -f unrealircd && pgrep -f atheme-services || exit 1
171+
172+
# Add Atheme-specific environment variables
173+
ENV ATHEME_CONF="/usr/local/atheme/etc/atheme.conf" \
174+
ATHEME_DATA="/usr/local/atheme/var" \
175+
ATHEME_MODULES="/usr/local/atheme/modules" \
176+
# UnrealIRCd module management
177+
UNREALIRCD_CONTRIB="/usr/local/unrealircd/contrib" \
178+
UNREALIRCD_MODULES="/usr/local/unrealircd/modules"
179+
180+
# Default command - use our startup script
181+
CMD ["/usr/local/bin/start-services", "start"]

0 commit comments

Comments
 (0)