-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Dockerfile
185 lines (147 loc) · 6.48 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# syntax=docker/dockerfile:1
FROM debian:12-slim AS msmtp-builder
ENV MSMTP_VERSION="1.8.27"
ENV MSMTP_GPG_KEY="2F61B4828BBA779AECB3F32703A2A4AB1E32FD34"
# Install required packages
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get -q -y install --no-install-recommends \
wget ca-certificates libgnutls28-dev xz-utils \
gpg dirmngr gpg-agent \
build-essential automake libtool gettext texinfo pkg-config
RUN wget -O /msmtp.tar.xz -nv https://marlam.de/msmtp/releases/msmtp-${MSMTP_VERSION}.tar.xz \
&& wget -O /msmtp.tar.xz.sig -nv https://marlam.de/msmtp/releases/msmtp-${MSMTP_VERSION}.tar.xz.sig \
&& gpg --keyserver hkps://keyserver.ubuntu.com --keyserver-options timeout=10 --recv-keys ${MSMTP_GPG_KEY} \
&& gpg --verify /msmtp.tar.xz.sig /msmtp.tar.xz \
&& tar -xf /msmtp.tar.xz \
&& cd /msmtp-${MSMTP_VERSION} \
&& autoreconf -i \
&& ./configure --sysconfdir=/etc \
&& make \
&& make install
#############################################################################
FROM perl:5.40.0 AS builder
ENV RT="5.0.7"
ENV RTIR="5.0.6"
ENV RT_GPG_KEY="C49B372F2BF84A19011660270DF0A283FEAC80B2"
ARG ADDITIONAL_CPANM_ARGS=""
# use cpanm for dependencies
ENV RT_FIX_DEPS_CMD="cpanm --no-man-pages ${ADDITIONAL_CPANM_ARGS}"
# cpan non interactive mode
ENV PERL_MM_USE_DEFAULT=1
# Create RT user
RUN groupadd -g 1000 rt && useradd -u 1000 -g 1000 -Ms /bin/bash -d /opt/rt5 rt
# Install required packages
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get -q -y install --no-install-recommends \
ca-certificates wget gnupg graphviz libssl3 zlib1g \
gpg dirmngr gpg-agent \
libgd3 libexpat1 libpq5 w3m elinks links html2text lynx openssl libgd-dev
# Download and extract RT
RUN mkdir -p /src \
# import RT signing key
&& gpg --keyserver hkps://keyserver.ubuntu.com --keyserver-options timeout=10 --recv-keys ${RT_GPG_KEY} \
# download and extract RT
&& wget -O /src/rt.tar.gz -nv https://download.bestpractical.com/pub/rt/release/rt-${RT}.tar.gz \
&& wget -O /src/rt.tar.gz.asc -nv https://download.bestpractical.com/pub/rt/release/rt-${RT}.tar.gz.asc \
&& gpg --verify /src/rt.tar.gz.asc /src/rt.tar.gz \
&& mkdir -p /src/rt \
&& tar --strip-components=1 -C /src/rt -xzf /src/rt.tar.gz \
# download and extract RTIR
&& wget -O /src/rtir.tar.gz -nv https://download.bestpractical.com/pub/rt/release/RT-IR-${RTIR}.tar.gz \
&& wget -O /src/rtir.tar.gz.asc -nv https://download.bestpractical.com/pub/rt/release/RT-IR-${RTIR}.tar.gz.asc \
&& gpg --verify /src/rtir.tar.gz.asc /src/rtir.tar.gz \
&& mkdir -p /src/rtir \
&& tar --strip-components=1 -C /src/rtir -xzf /src/rtir.tar.gz
# Configure RT
RUN cd /src/rt \
# configure with all plugins and with the newly created user
&& ./configure --with-db-type=Pg --enable-gpg --enable-gd --enable-graphviz --enable-smime --enable-externalauth --with-web-user=rt --with-web-group=rt --with-rt-group=rt --with-bin-owner=rt --with-libs-owner=rt
# install https support for cpanm
RUN cpanm --no-man-pages install LWP::Protocol::https
# Install Sever::Starter without tests
# as they constanly fail with timeouts and thus break
# the build
# Also install CSS::Inliner so users can use $EmailDashboardInlineCSS
RUN cpanm --no-man-pages -n install Server::Starter CSS::Inliner \
# https://github.com/simonwistow/Module-Pluggable/issues/27
Module::Pluggable
# Install dependencies
RUN make -C /src/rt fixdeps \
&& make -C /src/rt testdeps \
&& make -C /src/rt install \
&& cpanm --install RT::Extension::MergeUsers \
&& cpanm --install RT::Extension::TerminalTheme \
# https://github.com/bestpractical/app-wsgetmail
# https://metacpan.org/dist/App-wsgetmail
&& cpanm --install App::wsgetmail
# Configure RTIR
RUN cd /src/rtir \
&& perl -I /src/rtir/lib Makefile.PL --defaultdeps \
&& make install
#############################################################################
FROM perl:5.40.0-slim
LABEL org.opencontainers.image.authors="firefart <[email protected]>"
LABEL org.opencontainers.image.title="Request Tracker"
LABEL org.opencontainers.image.source="https://github.com/firefart/rt-docker"
LABEL org.opencontainers.image.description="Request Tracker Docker Setup"
# Install required packages
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get -q -y install --no-install-recommends \
procps supervisor ca-certificates getmail6 wget curl gnupg graphviz libssl3 \
zlib1g libgd3 libexpat1 libpq5 w3m elinks links html2text lynx openssl cron bash \
libfcgi-bin \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# msmtp - disabled for now to use the newer version
# Create RT user
RUN useradd -u 1000 -Ms /bin/bash -d /opt/rt5 rt
# copy msmtp
COPY --from=msmtp-builder /usr/local/bin/msmtp /usr/bin/msmtp
COPY --from=msmtp-builder /usr/local/share/locale /usr/local/share/locale
# copy all needed stuff from the builder image
COPY --from=builder /usr/local/lib/perl5 /usr/local/lib/perl5
COPY --from=builder /opt/rt5 /opt/rt5
# run a final dependency check if we copied all
RUN perl /opt/rt5/sbin/rt-test-dependencies --with-pg --with-fastcgi --with-gpg --with-graphviz --with-gd
# supervisord config
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN mkdir -p /var/log/supervisor/ \
&& chown rt:rt /var/log/supervisor/ \
&& mkdir -p /var/run/supervisord \
&& chown rt:rt /var/run/supervisord
# msmtp config
RUN mkdir /msmtp \
&& chown rt:rt /msmtp \
# also fake sendmail for cronjobs
&& ln -s /usr/bin/msmtp /usr/sbin/sendmail
# getmail
RUN mkdir -p /getmail \
&& chown rt:rt /getmail
# gpg
RUN mkdir -p /opt/rt5/var/data/gpg \
&& chown rt:rt /opt/rt5/var/data/gpg
# smime
RUN mkdir -p /opt/rt5/var/data/smime \
&& chown rt:rt /opt/rt5/var/data/smime
# shredder dir
RUN mkdir -p /opt/rt5/var/data/RT-Shredder \
&& chown rt:rt /opt/rt5/var/data/RT-Shredder
# RTIR Database stuff for setup
COPY --chown=rt:rt --from=builder /src/rtir/etc /opt/rtir
# wsgetmail
COPY --chown=rt:rt --from=builder /usr/local/bin/wsgetmail /usr/local/bin/wsgetmail
# remove default cron jobs
RUN rm -f /etc/cron.d/* \
&& rm -f /etc/cron.daily/* \
&& rm -f /etc/cron.hourly/* \
&& rm -f /etc/cron.monthly/* \
&& rm -f /etc/cron.weekly/* \
&& rm -f /var/spool/cron/crontabs/*
COPY --chown=root:root --chmod=0700 cron_entrypoint.sh /root/cron_entrypoint.sh
# update PATH
ENV PATH="${PATH}:/opt/rt5/sbin:/opt/rt5/bin"
EXPOSE 9000
USER rt
WORKDIR /opt/rt5/
CMD [ "/usr/bin/supervisord" ]
HEALTHCHECK --interval=10s --timeout=3s --start-period=10s --retries=3 CMD cgi-fcgi -connect localhost:9000 -bind || exit 1