-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathDockerfile
More file actions
96 lines (77 loc) · 3.09 KB
/
Dockerfile
File metadata and controls
96 lines (77 loc) · 3.09 KB
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
ARG DEBIAN_VERSION=trixie
# Stage 1: builder debian image
FROM debian:${DEBIAN_VERSION} as builder
# install package building helpers
# rsyslog for logging (ref https://github.com/stilliard/docker-pure-ftpd/issues/17)
# Enable deb-src repos needed for apt-get source & build-dep:
# Trixie+ uses DEB822 format (.sources files); older distros use traditional sources.list
ENV DEBIAN_FRONTEND noninteractive
RUN if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/debian.sources; \
else \
sed -i '/^deb /p;s/^deb /deb-src /' /etc/apt/sources.list; \
fi && \
apt-get -y update && \
apt-get -y --fix-missing install dpkg-dev debhelper &&\
apt-get -y build-dep pure-ftpd
# Build from source - we need to remove the need for CAP_SYS_NICE and CAP_DAC_READ_SEARCH
RUN mkdir /tmp/pure-ftpd/ && \
cd /tmp/pure-ftpd/ && \
apt-get source pure-ftpd && \
cd pure-ftpd-* && \
./configure --with-tls | grep -v '^checking' | grep -v ': Entering directory' | grep -v ': Leaving directory' && \
sed -i '/CAP_SYS_NICE,/d; /CAP_DAC_READ_SEARCH/d; s/CAP_SYS_CHROOT,/CAP_SYS_CHROOT/;' src/caps_p.h && \
dpkg-buildpackage -b -uc | grep -v '^checking' | grep -v ': Entering directory' | grep -v ': Leaving directory'
# Stage 2: actual pure-ftpd image
FROM debian:${DEBIAN_VERSION}-slim
# feel free to change this ;)
LABEL maintainer "Andrew Stilliard <andrew.stilliard@gmail.com>"
# install dependencies
# FIXME : libcap2 is not a dependency anymore. .deb could be fixed to avoid asking this dependency
ENV DEBIAN_FRONTEND noninteractive
ARG SSL_LIB=libssl3
RUN apt-get -y update && \
apt-get --no-install-recommends --yes install \
libc6 \
libcap2 \
libmariadb3 \
libpam0g \
${SSL_LIB} \
libsodium23 \
openbsd-inetd \
openssl \
perl \
rsyslog
COPY --from=builder /tmp/pure-ftpd/*.deb /tmp/pure-ftpd/
# install the new deb files
RUN dpkg -i /tmp/pure-ftpd/pure-ftpd-common*.deb &&\
dpkg -i /tmp/pure-ftpd/pure-ftpd_*.deb && \
# dpkg -i /tmp/pure-ftpd/pure-ftpd-ldap_*.deb && \
# dpkg -i /tmp/pure-ftpd/pure-ftpd-mysql_*.deb && \
# dpkg -i /tmp/pure-ftpd/pure-ftpd-postgresql_*.deb && \
rm -Rf /tmp/pure-ftpd
# prevent pure-ftpd upgrading
RUN apt-mark hold pure-ftpd pure-ftpd-common
# setup ftpgroup and ftpuser
RUN groupadd ftpgroup &&\
useradd -g ftpgroup -d /home/ftpusers -s /dev/null ftpuser
# configure rsyslog logging
RUN echo "" >> /etc/rsyslog.conf && \
echo "#PureFTP Custom Logging" >> /etc/rsyslog.conf && \
echo "ftp.* /var/log/pure-ftpd/pureftpd.log" >> /etc/rsyslog.conf && \
echo "Updated /etc/rsyslog.conf with /var/log/pure-ftpd/pureftpd.log"
# setup run/init file
COPY run.sh /run.sh
RUN chmod u+x /run.sh
# cleaning up
RUN apt-get -y clean \
&& apt-get -y autoclean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*
# default publichost, you'll need to set this for passive support
ENV PUBLICHOST localhost
# couple available volumes you may want to use
VOLUME ["/home/ftpusers", "/etc/pure-ftpd/passwd"]
# startup
CMD /run.sh -l puredb:/etc/pure-ftpd/pureftpd.pdb -E -j -R -P $PUBLICHOST
EXPOSE 21 30000-30009