Skip to content

Commit b8d10f4

Browse files
committed
Add service and build
1 parent bf2072a commit b8d10f4

File tree

6 files changed

+180
-1
lines changed

6 files changed

+180
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish Docker image
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- develop
7+
tags:
8+
- "v[0-9]+.[0-9]+.[0-9]+"
9+
pull_request:
10+
branches:
11+
- "main"
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository_owner }}/vsftpd
16+
17+
jobs:
18+
build-and-push-image:
19+
name: Build and push Docker image
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Login to the registry
31+
uses: docker/login-action@v2
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Extract image metadata
38+
id: meta
39+
uses: docker/metadata-action@v4
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=ref,event=branch
44+
type=ref,event=pr
45+
type=semver,pattern=v{{version}}
46+
type=semver,pattern=v{{major}}.{{minor}}
47+
type=semver,pattern=v{{major}}
48+
49+
- name: Set up QEMU
50+
uses: docker/setup-qemu-action@v2
51+
52+
- name: Set up Docker Buildx
53+
uses: docker/setup-buildx-action@v2
54+
55+
- name: Build and push
56+
uses: docker/build-push-action@v3
57+
with:
58+
context: .
59+
push: true
60+
platforms: linux/amd64,linux/arm64
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM alpine:3
2+
3+
RUN apk add --no-cache \
4+
bash \
5+
vsftpd \
6+
openssl \
7+
&& rm -rf /var/cache/apk/*
8+
9+
COPY vsftpd.conf /etc/vsftpd/vsftpd.conf
10+
11+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
12+
RUN chmod +x /usr/local/bin/entrypoint.sh
13+
14+
CMD ["/usr/local/bin/entrypoint.sh"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Dmitry Lebed
3+
Copyright (c) 2023 Dzmitry Lebiadz
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
11
# vsftpd-docker
2+
23
vsftpf (very secure FTP daemon) alpine container
4+
5+
## Available options
6+
7+
| Option | Description |
8+
| ------------- | ------------------------------------- |
9+
| `FTP_USER` | Username for login. `user` by deafult |
10+
| `FTP_PASS` | Password for login. `pass` by default |
11+
| `FTP_LOGGING` | Enable logging. `NO` by default |
12+
13+
Other options may be set using `VSFTPD_` prefix. For example to enable passive mode you can do next:
14+
15+
```bash
16+
docker run -d \
17+
-p 20-21:20-21 \
18+
-p 21100-21110:21100-21110 \
19+
-e FTP_USER=<user> \
20+
-e FTP_PASS=<password> \
21+
-e VSFTPD_pasv_enable=YES \
22+
-e VSFTPD_pasv_address=<server_ip> \
23+
-e VSFTPD_pasv_min_port=21100 \
24+
-e VSFTPD_pasv_max_port=21110 \
25+
-v /path/to/ftp:/home/vsftpd/<user> \
26+
--name vsftpd --restart=always m0thman/vsftpd
27+
```

entrypoint.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
FTP_USER=${FTP_USER:-user}
4+
FTP_PASS=${FTP_PASS:-pass}
5+
FTP_LOGGING=${FTP_LOGGING:-NO}
6+
7+
# Prepare user and directory
8+
addgroup -g 1212 $FTP_USER
9+
adduser -D -h /home/vsftpd/$FTP_USER -s /bin/false -G $FTP_USER -u 1212 $FTP_USER
10+
echo "$FTP_USER:$FTP_PASS" | /usr/sbin/chpasswd
11+
chown -R $FTP_USER:$FTP_USER /home/vsftpd/$FTP_USER
12+
13+
# Prepare config file
14+
CONFIG_FILE=/etc/vsftpd/vsftpd.conf
15+
16+
# Disable logging if FTP_LOGGING is not YES
17+
if [ "$FTP_LOGGING" != "YES" ]; then
18+
sed -i 's/^xferlog_enable=.*/xferlog_enable=NO/' "$CONFIG_FILE"
19+
sed -i 's/^log_ftp_protocol=.*/log_ftp_protocol=NO/' "$CONFIG_FILE"
20+
fi
21+
22+
# Copy environment variables starting with VSFTPD_ and append them to CONFIG_FILE file
23+
for var in $(env | grep '^VSFTPD_'); do
24+
name=$(echo "$var" | awk -F= '{print $1}')
25+
value=$(echo "$var" | awk -F= '{print $2}')
26+
27+
echo "${name#VSFTPD_}=$value" >> "$CONFIG_FILE"
28+
done
29+
30+
cat << TXT
31+
*******************************************************
32+
* Server configuration *
33+
*******************************************************
34+
TXT
35+
cat "$CONFIG_FILE"
36+
cat << TXT
37+
*******************************************************
38+
TXT
39+
40+
# Start logging if FTP_LOGGING is YES
41+
if [ "$FTP_LOGGING" = "YES" ]; then
42+
echo "Enabling logging"
43+
44+
LOG_FILE=`grep ^vsftpd_log_file $CONFIG_FILE | cut -d= -f2`
45+
touch $LOG_FILE
46+
tail -f $LOG_FILE >> /dev/stdout &
47+
fi
48+
49+
# Run vsftpd
50+
exec /usr/sbin/vsftpd $CONFIG_FILE

vsftpd.conf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
anonymous_enable=NO
2+
#anon_upload_enable=YES
3+
#anon_mkdir_write_enable=YES
4+
5+
local_enable=YES
6+
chroot_local_user=YES
7+
passwd_chroot_enable=YES
8+
allow_writeable_chroot=YES
9+
10+
write_enable=YES
11+
local_umask=022
12+
13+
ftpd_banner=Welcome to FTP service.
14+
dirmessage_enable=YES
15+
connect_from_port_20=YES
16+
17+
listen=YES
18+
#listen_ipv6=YES
19+
20+
# Logging
21+
xferlog_enable=YES
22+
xferlog_file=/var/log/xferlog.log
23+
xferlog_std_format=NO
24+
25+
log_ftp_protocol=YES
26+
vsftpd_log_file=/var/log/vsftpd.log
27+
28+
# Other options

0 commit comments

Comments
 (0)