diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..63c3c6b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine:3.13 + +RUN apk add --no-cache \ + openssh-server \ + rsync + +RUN mkdir -p /root/.ssh && cp /etc/ssh/sshd_config /etc/default_sshd_config diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3a1a9a7 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: build +build: + docker build -t registry.0xdad.com/rsync-ssh-server:latest . + +.PHONY: deploy +deploy: build + docker push registry.0xdad.com/rsync-ssh-server:latest diff --git a/README.md b/README.md index 0987081..6880c9e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ # docker-rsync-server +This is a simple docker image definition for starting an SSH server that is used for rsyncing to volume mounts. + +## Volumes + +| path | description | +|----------------------------|---------------------------------------| +| /root/.ssh/authorized_keys | the ssh keys to allow for auth | +| /etc/ssh | location for SSH host keys and config | +| anywhere else | the locations available for rsync | diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..b1e90b6 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/sh +set -eu + +ssh-keygen -A + +if [ ! -e '/etc/ssh/sshd_config' ]; then + cp /etc/default_sshd_config /etc/ssh/sshd_config +fi + +/usr/sbin/sshd + +while pgrep -f /usr/sbin/sshd; do + sleep 5 +done + +>&2 echo 'SSHD is no longer running' +exit 1