Commit d8ab687c885e8f49f6cffdd350c1b7f2b73f4ec0

Authored by Liu Haoyu
0 parents

ftp文件监听服务创建

Dockerfile 0 → 100644
  1 +++ a/Dockerfile
  1 +FROM ubuntu:18.04
  2 +
  3 +ENV LANG C.UTF-8
  4 +ENV TZ=Asia/Shanghai
  5 +# Set time zone
  6 +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone
  7 +RUN mkdir /data
  8 +WORKDIR /data
  9 +COPY mc /usr/sbin/
  10 +COPY docker-entrypoint.sh /usr/sbin/docker-entrypoint.sh
  11 +COPY mc_watcher.sh /usr/sbin/mc_watcher.sh
  12 +RUN chmod +x /usr/sbin/mc_watcher.sh
  13 +RUN chmod +x /usr/sbin/docker-entrypoint.sh
  14 +ENTRYPOINT ["docker-entrypoint.sh"]
0 15 \ No newline at end of file
... ...
README.md 0 → 100644
  1 +++ a/README.md
  1 +# Ftp-Watcher
  2 +
  3 +## Version:
  4 +`1.0`
  5 +
  6 +## 依赖:
  7 + - minio
  8 + - docker
  9 + - docker-compose (optional)
  10 +
  11 +## 配置参数:
  12 +
  13 + | 参数 | 说明 | 是否必须 | 例子 |
  14 + |-|-|-|-|
  15 + | udp_server_ip | udp服务器ip, 用于接收推送文件minio路径 | 是 | 127.0.01 |
  16 + | udp_server_port | udp服务器port, 用于接收推送文件minio路径 | 是 | 8080 |
  17 + | minio_endpoint | MinIO服务器地址 | 是 | http://localhost:9000 |
  18 + | minio_access_key | MinIO 用户名 | 是 | admin |
  19 + | minio_secret_key | MinIO密钥 | 是 | 123456 |
  20 + | bucket_name | 目标桶名称 | 是 | bucket |
  21 +
  22 +## 使用方法
  23 +
  24 +### Docker-compose
  25 +
  26 +`docker-compose up -d`
  27 +
  28 +### Docker
  29 +
  30 +```
  31 +docker run -id --name my-ftpWatcher \
  32 + --restart always \
  33 + -v ./data:/data \
  34 + -e udp_server_ip='127.0.0.1' \
  35 + -e udp_server_port='8080' \
  36 + -e minio_endpoint='http://localhost:9000' \
  37 + -e minio_access_key='admin' \
  38 + -e minio_secret_key='123456' \
  39 + -e bucket_name='bucket' \
  40 + ftp-watcher:1.0
  41 +```
0 42 \ No newline at end of file
... ...
docker-compose.yml 0 → 100644
  1 +++ a/docker-compose.yml
  1 +version: "3"
  2 +
  3 +services:
  4 + ftpWatcher:
  5 + image: ftp-watcher:1.0
  6 + container_name: ftpWatcher
  7 + build:
  8 + context: ./
  9 + dockerfile: Dockerfile
  10 + volumes:
  11 + - ./data:/data
  12 + environment:
  13 + - udp_server_ip=192.168.60.67
  14 + - udp_server_port=8089
  15 + - minio_endpoint=http://192.168.10.58:6000
  16 + - minio_access_key=minioadmin
  17 + - minio_secret_key=minioadmin
  18 + - bucket_name=togoftp
0 19 \ No newline at end of file
... ...
docker-entrypoint.sh 0 → 100644
  1 +++ a/docker-entrypoint.sh
  1 +#!/bin/bash
  2 +
  3 +# mc alias set
  4 +mc alias set local ${minio_endpoint} ${minio_access_key} ${minio_secret_key}
  5 +nohup mc mirror -w /data/ local/${bucket_name}/ &
  6 +
  7 +# mc watcher
  8 +mc_watcher.sh
0 9 \ No newline at end of file
... ...
mc 0 → 100755
No preview for this file type
mc_watcher.sh 0 → 100644
  1 +++ a/mc_watcher.sh
  1 +#!/bin/bash
  2 +
  3 +TARGET_DIR="/data/"
  4 +
  5 +mc watch --recursive local/togoftp | while read events;
  6 +do
  7 + hostUrl=${events#*//}
  8 + echo "${hostUrl#*/}" > /dev/udp/${udp_server_ip}/${udp_server_port}
  9 +done
0 10 \ No newline at end of file
... ...