Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker pureftpd as first party server, with and without SSL #1022

Merged
merged 3 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions FluentFTP.Dockers/pureftpd/.travis.yml

This file was deleted.

174 changes: 77 additions & 97 deletions FluentFTP.Dockers/pureftpd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,97 +1,77 @@
#Stage 1 : builder debian image
FROM debian:buster as builder

# properly setup debian sources
ENV DEBIAN_FRONTEND noninteractive
RUN echo "deb http://http.debian.net/debian buster main\n\
deb-src http://http.debian.net/debian buster main\n\
deb http://http.debian.net/debian buster-updates main\n\
deb-src http://http.debian.net/debian buster-updates main\n\
deb http://security.debian.org buster/updates main\n\
deb-src http://security.debian.org buster/updates main\n\
" > /etc/apt/sources.list

# install package building helpers
# rsyslog for logging (ref https://github.com/stilliard/docker-pure-ftpd/issues/17)
RUN apt-get -y update && \
apt-get -y --force-yes --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:buster-slim

# feel free to change this ;)
LABEL maintainer "Andrew Stilliard <[email protected]>"

# install dependencies
# FIXME : libcap2 is not a dependency anymore. .deb could be fixed to avoid asking this dependency
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get -y update && \
apt-get --no-install-recommends --yes install \
libc6 \
libcap2 \
libmariadb3 \
libpam0g \
libssl1.1 \
lsb-base \
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
# Remove \r from the windows style \r\n newline.
RUN sed -i -e "s/\r//" /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
#
# FluentFTP Integration Test Server: pureftpd
#

FROM python:3-slim AS prebuild

SHELL ["/bin/bash", "-c"]

WORKDIR /usr/src/app
RUN pip install --user apt-smart

WORKDIR /root
RUN python3 /root/.local/bin/apt-smart -b > deb_mirror

#
# Stage 1: build & production
#

FROM debian:bullseye-slim AS build

LABEL Description="FluentFTP pureftpd docker image based on Debian Bullseye."

SHELL ["/bin/bash", "-c"]

ARG DEBIAN_FRONTEND=noninteractive
ARG APT_CMD='apt install -y --no-install-recommends'

COPY --from=prebuild /root/deb_mirror /root/deb_mirror

WORKDIR /
RUN mapfile -t lines < /root/deb_mirror && \
DEB_MIRROR=${lines[0]} && \
echo $DEB_MIRROR && \
\
printf "\
deb $DEB_MIRROR bullseye main\n\
# deb-src $DEB_MIRROR bullseye main\n\
\n\
deb http://deb.debian.org/debian-security bullseye-security main contrib\n\
# deb-src http://deb.debian.org/debian-security bullseye-security main contrib\n\
\n\
# bullseye-updates, previously known as 'volatile'\n\
deb $DEB_MIRROR bullseye-updates main\n\
# deb-src $DEB_MIRROR bullseye-updates main\n\
" > /etc/apt/sources.list

RUN apt update && apt upgrade -y && apt install -y apt-utils && \
\
$APT_CMD \
openssl \
pure-ftpd

COPY run-pureftpd.sh /usr/sbin/

RUN sed -i -e "s/\r//" /usr/sbin/run-pureftpd.sh && \
chmod +x /usr/sbin/run-pureftpd.sh && \
\
useradd -m -p savatlcb.1m26 fluentuser && \
\
mkdir -p /home/fluentuser/ && \
chown -R fluentuser:users /home/fluentuser && \
\
openssl req -x509 -newkey rsa:4096 \
-keyout /etc/ssl/private/pure-ftpd.key -out /etc/ssl/certs/pure-ftpd.crt \
-subj "/C=US/ST=State/L=/O=Dev/CN=fluentftp" \
-nodes -days 3650 && \
\
chmod 0600 /etc/ssl/private/pure-ftpd.key && \
chmod 0640 /etc/ssl/private/pure-ftpd.key && \
\
cat /etc/ssl/certs/pure-ftpd.crt /etc/ssl/private/pure-ftpd.key > /etc/ssl/private/pure-ftpd.pem

VOLUME ["/home/fluentuser", "/var/log/pureftpd"]

EXPOSE 20 21

CMD ["/usr/sbin/run-pureftpd.sh"]
21 changes: 0 additions & 21 deletions FluentFTP.Dockers/pureftpd/LICENSE

This file was deleted.

72 changes: 0 additions & 72 deletions FluentFTP.Dockers/pureftpd/Makefile

This file was deleted.

Loading