Skip to content

Commit

Permalink
Merge pull request #7 from sbesson/alpine_3.15.0
Browse files Browse the repository at this point in the history
Alpine 3.15.0
  • Loading branch information
sbesson authored Jan 18, 2022
2 parents c72bb1a + 1b0dc8d commit d0519c2
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 29 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: Build

on:
push:
pull_request:

env:
IMAGE_NAME: openmicroscopy/vsftpd-anonymous-upload

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Test
run: ./test.sh
# Push image to DockerHub
push:
needs: build

runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u omereleases --password-stdin

- name: Push image
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_NAME:$VERSION
docker push $IMAGE_NAME:$VERSION
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# Dockerfile for vsftpd
#

FROM alpine:3.7
FROM alpine:3.15.0
MAINTAINER [email protected]

RUN set -xe \
&& apk add -U vsftpd \
&& passwd -l root \
&& rm -rf /var/cache/apk/*

ADD vsftpd.conf vsftpd.email_passwords vsftpd.banner /etc/vsftpd/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vsftpd Anonymous Upload Docker Image

[![Build Status](https://travis-ci.org/manics/vsftpd-anonymous-upload-docker.svg?branch=master)](https://travis-ci.org/manics/vsftpd-anonymous-upload-docker)
[![Actions Status](https://github.com/ome/vsftpd-anonymous-upload-docker/workflows/Build/badge.svg)](https://github.com/ome/vsftpd-anonymous-upload-docker/actions)

[vsftpd](https://security.appspot.com/vsftpd.html) is a GPL licensed FTP server for UNIX systems, including Linux.

Expand All @@ -11,7 +11,7 @@ A very minimal level of access control is provided by listing allowed emails in
Passive FTP ports are configured to fit with the default Kubernetes NodePort range since FTP does not support port-forwarding between different ports.

```bash
docker run -d --name vsftpd -p 32021:21 -p 32022-32041:32022-32041 -v /var/lib/ftp/incoming vsftpd-anonymous-upload
docker run -d --name vsftpd -p 21:21 -p 32022-32041:32022-32041 -v /var/lib/ftp/incoming vsftpd-anonymous-upload
```

## Client
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
version: "3"

services:
ftpserver:
build: .
restart: on-failure
ftpclient:
build: ftpclient
tty: true
depends_on:
- "ftpserver"
10 changes: 10 additions & 0 deletions ftpclient/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:latest

RUN apk --no-cache add lftp ca-certificates openssh

COPY generate.sh /tmp/generate.sh
WORKDIR /data
RUN sh /tmp/generate.sh

ENTRYPOINT ["lftp"]
CMD ["-f", "/tmp/upload.scp", "-d"]
22 changes: 22 additions & 0 deletions ftpclient/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#! /bin/sh
N=${N:-10000}
THREADS=${THREADS:-10}
USER=${USER:-anonymous}
PASS=${PASS:-allowed@example.org}
SERVER=${SERVER:-ftpserver}

# Create data and checksum
mkdir -p /tmp/test && cd /tmp/test
for i in $(seq 1 $N); do
echo $date-$i > $i
done
find * -type f -exec sha1sum {} \; | grep -v SHASUMS > SHASUMS

# Generate upload script
echo "open -u $USER,$PASS $SERVER" > /tmp/upload.scp
echo "mkdir /incoming/parallel" >> /tmp/upload.scp
echo "set ftp:use-site-utime false" >> /tmp/upload.scp
echo "set ftp:use-site-utime2 false" >> /tmp/upload.scp
echo "mirror -p --parallel=$THREADS -R /tmp/test/ /incoming/test/" >> /tmp/upload.scp
echo "bye" >> /tmp/upload.scp

2 changes: 1 addition & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ftp:
pullPolicy: IfNotPresent
service:
type: ClusterIP
externalPort: 32021
externalPort: 21
internalPort: 21
passive:
portMin: 32022
Expand Down
23 changes: 5 additions & 18 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@

set -eu

docker rm -f test-vsftpd || true
docker build -t vsftpd-anonymous-upload-docker .
docker run -d --rm --name test-vsftpd -p 32021:21 -p 32022-32041:32022-32041 vsftpd-anonymous-upload-docker
sleep 5
docker-compose down
docker-compose build
docker-compose up -d
docker wait vsftpd-anonymous-upload-docker_ftpclient_1
docker exec vsftpd-anonymous-upload-docker_ftpserver_1 sh -c "cd incoming/test && sha1sum -c SHASUMS"

# Note ftp returns exit code 0 even if an error occurred
ftp -n localhost 32021 << EOF
user anonymous [email protected]
passive
cd incoming
put test.sh
quit
EOF

docker logs test-vsftpd

CHECK=$(docker exec test-vsftpd find /var/lib/ftp/incoming | tr '\n' ' ')
test "$CHECK" = '/var/lib/ftp/incoming /var/lib/ftp/incoming/test.sh '
docker rm -f test-vsftpd

0 comments on commit d0519c2

Please sign in to comment.