sftpgo-mirror/docker/sftpgo/alpine
Nicola Murino 4e41a5583d refactoring: add common package
The common package defines the interfaces that a protocol must implement
and contain code that can be shared among supported protocols.

This way should be easier to support new protocols
2020-07-24 23:39:38 +02:00
..
docker-entrypoint.sh docker: remove serve command from entrypoint in alpine 2020-02-14 15:13:39 +01:00
Dockerfile refactoring: add common package 2020-07-24 23:39:38 +02:00
README.md refactoring: add common package 2020-07-24 23:39:38 +02:00
sftpgo.service docker: update docs 2020-03-14 15:27:03 +01:00

SFTPGo with Docker and Alpine

This DockerFile is made to build image to host multiple instances of SFTPGo started with different users.

Example

1003 is a custom uid:gid for this instance of SFTPGo

# Prereq on docker host
sudo groupadd -g 1003 sftpgrp && \
  sudo useradd -u 1003 -g 1003 sftpuser -d /home/sftpuser/ && \
  sudo -u sftpuser mkdir /home/sftpuser/{conf,data} && \
  curl https://raw.githubusercontent.com/drakkan/sftpgo/master/sftpgo.json -o /home/sftpuser/conf/sftpgo.json

# Edit sftpgo.json as you need

# Get and build SFTPGo image.
# Add --build-arg TAG=LATEST to build the latest tag or e.g. TAG=v1.0.0 for a specific tag/commit.
# Add --build-arg FEATURES=<build features comma separated> to specify the features to build.
git clone https://github.com/drakkan/sftpgo.git && \
  cd sftpgo && \
  sudo docker build -t sftpgo docker/sftpgo/alpine/

# Initialize the configured provider. For PostgreSQL and MySQL providers you need to create the configured database and the "initprovider" command will create the required tables.
sudo docker run --name sftpgo \
  -e PUID=1003 \
  -e GUID=1003 \
  -v /home/sftpuser/conf/:/srv/sftpgo/config \
  sftpgo initprovider -c /srv/sftpgo/config

# Start the image
sudo docker rm sftpgo && sudo docker run --name sftpgo \
  -e SFTPGO_LOG_FILE_PATH= \
  -e SFTPGO_CONFIG_DIR=/srv/sftpgo/config \
  -e SFTPGO_HTTPD__TEMPLATES_PATH=/srv/sftpgo/web/templates \
  -e SFTPGO_HTTPD__STATIC_FILES_PATH=/srv/sftpgo/web/static \
  -e SFTPGO_HTTPD__BACKUPS_PATH=/srv/sftpgo/backups \
  -p 8080:8080 \
  -p 2022:2022 \
  -e PUID=1003 \
  -e GUID=1003 \
  -v /home/sftpuser/conf/:/srv/sftpgo/config \
  -v /home/sftpuser/data:/data \
  -v /home/sftpuser/backups:/srv/sftpgo/backups \
  sftpgo

The script entrypoint.sh makes sure to correct the permissions of directories and start the process with the right user.

Several images can be run with different parameters.

Custom systemd script

An example of systemd script is present here, with Environment parameter to set PUID and GUID

WorkingDirectory parameter must be exist with one file in this directory like sftpgo-${PUID}.env corresponding to the variable file for SFTPGo instance.