Skip to content

Commit 2f790b7

Browse files
committed
Added ftp container
1 parent 42a78ef commit 2f790b7

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

docker/storage/entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
mkdir -p /data/solr/
88
mkdir -p /data/dns/
9+
mkdir -p /data/ftp/
910
mkdir -p /data/cache/
1011

1112
find /data/ -type d -print0 | xargs -0 --no-run-if-empty chmod 777

docker/vsftpd/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM ubuntu:14.04
2+
3+
ENV VSFTP_USER dev
4+
ENV VSFTP_PASSWORD dev
5+
ENV VSFTP_PATH /data/ftp/
6+
7+
RUN apt-get update && \
8+
apt-get install -y vsftpd supervisor net-tools
9+
10+
RUN mkdir -p /var/run/vsftpd/empty
11+
RUN mkdir -p /var/log/supervisor
12+
13+
COPY entrypoint.sh /entrypoint.sh
14+
COPY conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
15+
COPY conf/vsftpd.conf /etc/vsftpd.conf
16+
17+
RUN mkdir -p /data/ftp/
18+
19+
VOLUME "/data/ftp/"
20+
21+
EXPOSE 20
22+
EXPOSE 21
23+
EXPOSE 12020
24+
EXPOSE 12021
25+
EXPOSE 12022
26+
EXPOSE 12023
27+
EXPOSE 12024
28+
EXPOSE 12025
29+
30+
ENTRYPOINT ["/entrypoint.sh"]
31+
32+
CMD ["supervisord"]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:vsftpd]
5+
command=vsftpd

docker/vsftpd/conf/vsftpd.conf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
listen=YES
2+
anonymous_enable=NO
3+
local_enable=YES
4+
write_enable=YES
5+
anon_upload_enable=NO
6+
anon_mkdir_write_enable=NO
7+
dirmessage_enable=YES
8+
use_localtime=YES
9+
xferlog_enable=YES
10+
connect_from_port_20=YES
11+
secure_chroot_dir=/var/run/vsftpd/empty
12+
pam_service_name=vsftpd
13+
rsa_cert_file=/etc/ssl/private/vsftpd.pem
14+
max_per_ip=100
15+
max_clients=100
16+
17+
pasv_min_port=12020
18+
pasv_max_port=12025
19+
20+
file_open_mode=0666
21+
local_umask=000
22+
23+
allow_writeable_chroot=YES
24+
vsftpd_log_file=/var/log/vsftpd.log
25+
background=NO

docker/vsftpd/entrypoint.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -e
3+
4+
#############################
5+
## USER
6+
#############################
7+
8+
mkdir -p "${FTP_PATH}"
9+
10+
if ( id "${FTP_USER}" ); then
11+
echo "User ${FTP_USER} already exists"
12+
else
13+
echo "Creating user and group ${FTP_USER}"
14+
ENC_PASS=$(perl -e 'print crypt($ARGV[0], "password")' "${FTP_PASSWORD}")
15+
groupadd -g "${EFFECTIVE_GID}" "${FTP_USER}"
16+
useradd -d "${FTP_PATH}" -m -p "${ENC_PASS}" -u "${EFFECTIVE_UID}" --gid "${FTP_USER}" -s /bin/sh "${FTP_USER}"
17+
fi
18+
19+
#############################
20+
## COMMAND
21+
#############################
22+
23+
case "$1" in
24+
25+
## Supervisord (start daemons)
26+
supervisord)
27+
## Register IP
28+
ETH0_IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
29+
mkdir -p /data/dns/
30+
chmod 777 /data/dns/
31+
echo "${ETH0_IP}" > /data/dns/ftp.ip
32+
echo "${ETH0_IP} ftp ftp_1" > /data/dns/ftp.hosts
33+
34+
## Start services
35+
exec supervisord
36+
;;
37+
38+
## All other commands
39+
*)
40+
exec "$@"
41+
;;
42+
esac

0 commit comments

Comments
 (0)