Raspberry and JavaFTP on Docker

Raspberry and JavaFTP on Docker

Enable the JavaFTP server on docker.

Here is the Makefile
IMAGE=sillycat/public
TAG=raspberrypi-javaftp
NAME=raspberrypi-javaftp

prepare:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-arm32-vfp-hflt.tar.gz" -P install/
wget http://apache.mirrors.lucidnetworks.net/mina/ftpserver/1.0.6/dist/ftpserver-1.0.6.tar.gz -P install/
#tar zxvf ftpserver-1.0.6.tar.gz
#tar -cvzf ./apache-ftpserver-1.0.6.tgz ./apache-ftpserver-1.0.6

docker-context:

build: docker-context
# docker build --no-cache -t $(IMAGE):$(TAG) .
docker build -t $(IMAGE):$(TAG) .

run:
docker run -d -p 2121:2121 -p 30000-30039:30000-30039 -v /opt/disk1/sillycat:/tool/apache-ftpserver-1.0.6/res/home/sillycat --name $(NAME) $(IMAGE):$(TAG)

debug:
docker run -ti -p 2121:2121 -p 30000-30039:30000-30039 -v /opt/disk1/sillycat:/tool/apache-ftpserver-1.0.6/res/home/sillycat --name $(NAME) $(IMAGE):$(TAG) /bin/bash

clean:
docker stop ${NAME}
docker rm ${NAME}

logs:
docker logs ${NAME}

publish:
docker push ${IMAGE}:${TAG}

fetch:
docker pull ${IMAGE}:${TAG}


Here is the Dockerfile
#Set up FTP in Docker

#Prepre the OS
FROM resin/rpi-raspbian:jessie
MAINTAINER Carl Luo <[email protected]>

ENV DEBIAN_FRONTEND noninteractive
RUN echo "deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi\n\
" > /etc/apt/sources.list
RUN apt-get -y update
RUN apt-get -y dist-upgrade

#install java env
ADD install/jdk-8u91-linux-arm32-vfp-hflt.tar.gz /tool/
RUN update-alternatives --install /usr/bin/java java /tool/jdk1.8.0_91/bin/java 1

#install ftp soft
ADD install/apache-ftpserver-1.0.6.tgz /tool/

#configure the server
ADD     conf/ftpd-typical.xml  /tool/apache-ftpserver-1.0.6/res/conf/
ADD     conf/users.properties  /tool/apache-ftpserver-1.0.6/res/conf/

RUN     mkdir -p /tool/apache-ftpserver-1.0.6/res/home/sillycat
RUN     mkdir -p /tool/apache-ftpserver-1.0.6/res/home/kiko
RUN     mkdir -p /tool/apache-ftpserver-1.0.6/res/home/xieqiuyuan

#start the application
EXPOSE  2121 30000-30040
RUN     mkdir -p /app/
ADD     start.sh /app/
WORKDIR /app/
CMD [ "./start.sh" ]

Here is the start.sh
#!/bin/sh -ex

#start the ftp
cd /tool/apache-ftpserver-1.0.6
bin/ftpd.sh res/conf/ftpd-typical.xml

The typical configuration for ftp in ftp-typical.xml is as follow:
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
  http://mina.apache.org/ftpserver/spring/v1 http://mina.apache.org/ftpserver/ftpserver-1.0.xsd

  "
id="nasServer"
        max-logins="20"
        anon-enabled="false"
        max-login-failures="3"
        login-failure-delay="500">
<listeners>
<nio-listener name="default" port="2121">

    <ssl>

                <keystore file="./res/ftpserver.jks" password="password" />
                    </ssl>
                    <data-connection idle-timeout="60">
                      <active enabled="true" local-port="30040" ip-check="true" />
                      <passive ports="30000-30039" external-address="72.179.1.15" />
          </data-connection>

</nio-listener>

</listeners>
<file-user-manager file="./res/conf/users.properties" encrypt-passwords="false"/>
</server>

It works great. The only thing is that when I try to clean the old directory. I delete some directories which are useful. My god.

References:
http://sillycat.iteye.com/blog/2255064

https://mina.apache.org/ftpserver-project/configuration_passive_ports.html
https://mina.apache.org/ftpserver-project/configuration_listeners.html

猜你喜欢

转载自sillycat.iteye.com/blog/2316295