Skip to content

Commit

Permalink
Refactoring ftp upload image
Browse files Browse the repository at this point in the history
  • Loading branch information
atooni committed Jan 13, 2021
1 parent 8e0e6b2 commit 056ec49
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 12 deletions.
1 change: 1 addition & 0 deletions apacheds-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ENV USER_NAME=apacheds
RUN apk --no-cache add openldap-clients gettext vim \
&& addgroup "$USER_NAME" \
&& adduser \
--uid 10101 \
--disabled-password \
--gecos "" \
--home /home/"$USER_NAME" \
Expand Down
1 change: 0 additions & 1 deletion base-alpine/files/bin/uid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
cat /etc/passwd | grep -v "$USER_NAME" > /etc/passwd
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
chmod g-w /etc/passwd
fi
fi
set -x
Expand Down
34 changes: 27 additions & 7 deletions ftp-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
# The basic image to run Blended containers
FROM blended/base-alpine:1.0.1
FROM blended/base-alpine:3.12.1

LABEL Blended Development Team

RUN apk --no-cache add \
vsftpd
ENV USER_NAME=vsftp

ADD files/vsftpd.conf /etc/vsftpd.conf
ADD files/vsftpd.sh /opt
RUN addgroup "$USER_NAME" \
&& adduser \
--uid 10101 \
--disabled-password \
--gecos "" \
--ingroup "$USER_NAME" \
"$USER_NAME" \
&& adduser $USER_NAME root

RUN apk --no-cache add vsftpd

RUN chown -R $USER_NAME:$GROUP /home/$USER_NAME \
&& mkdir -p /opt/vsftp \
&& chgrp -R 0 /opt/vsftp \
&& chown -R :root /opt/vsftp \
&& chmod -R g+srwX /opt/vsftp \
&& chmod g+w /etc/passwd

ADD --chown=vsftp:0 files/vsftpd.conf /etc/vsftpd.conf
ADD --chown=vsftp:0 files/vsftpd.sh /opt/vsftp

RUN mkdir -p /var/vsftpd/uploads \
&& chown -R nobody:nogroup /var/vsftpd \
&& chmod -R 0777 /var/vsftpd/uploads \
&& chmod +x /opt/vsftpd.sh
&& chmod +x /opt/vsftp/vsftpd.sh

EXPOSE 20
EXPOSE 21
ENTRYPOINT [ "/usr/local/bin/uid.sh" ]

CMD [ "/opt/vsftpd.sh" ]
USER 10101
CMD [ "/bin/bash", "-l", "/opt/vsftp/vsftpd.sh" ]
3 changes: 3 additions & 0 deletions ftp-alpine/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -x
docker build -t blended/ftp-alpine:$(cat version.txt) .
5 changes: 3 additions & 2 deletions ftp-alpine/files/vsftpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ anon_root=/var/vsftpd
anon_mkdir_write_enable=YES
anon_other_write_enable=YES

run_as_launching_user=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
seccomp_sandbox=NO
xferlog_std_format=NO
vsftpd_log_file=/var/log/vsftpd.log
xferlog_std_format=YES
vsftpd_log_file=/opt/vsftp/vsftpd.log
log_ftp_protocol=YES
listen=YES
syslog_enable=NO
5 changes: 3 additions & 2 deletions ftp-alpine/files/vsftpd.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

touch /var/log/vsftpd.log
umask 002
touch /opt/vsftp/vsftpd.log
/usr/sbin/vsftpd
tail -f /var/log/vsftpd.log
tail -f /opt/vsftp/vsftpd.log
1 change: 1 addition & 0 deletions ftp-alpine/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.2

0 comments on commit 056ec49

Please sign in to comment.