Initial commit

This commit is contained in:
Jan Christian Grünhage 2017-04-11 11:09:44 +02:00
commit efac43bfbb
Signed by: jcgruenhage
GPG key ID: 321A67D9EE8BC3E1
3 changed files with 70 additions and 0 deletions

46
Dockerfile Normal file
View file

@ -0,0 +1,46 @@
FROM alpine:edge
MAINTAINER Jan Christian Grünhage <me@jcg.re>
ENV UID 192
ENV GID 192
ENV GOPATH /tmp/gopath
RUN apk add --update \
borgbackup \
su-exec \
go \
ca-certificates \
build-base \
git \
openssh \
bash \
nano \
shadow \
s6 \
&& mkdir /tmp/gopath \
&& mkdir -p /backup/config \
&& mkdir -p /backup/storage \
&& mkdir -p /home/borg \
&& go get git.jcg.re/jcgruenhage/borg-gen-auth-keys.git \
&& apk del --purge \
go \
build-base \
git \
&& mv $GOPATH/bin/borg-gen-auth-keys.git /usr/local/bin/borg-gen-auth-keys \
&& rm -rf \
/tmp \
/var/cache/apk/* \
/usr/lib/python3.6/__pycache__ \
&& addgroup -g $GID -S borg \
&& adduser -S -u $UID -g $GID -h /home/borg borg \
&& usermod -p "*" borg \
&& usermod -s /bin/bash borg \
&& passwd -u borg
ADD root /
VOLUME /backup/storage
VOLUME /backup/config
EXPOSE 22
CMD ["/usr/local/bin/run.sh"]

2
root/etc/s6.d/sshd/run Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
/usr/sbin/sshd -D -d

22
root/usr/local/bin/run.sh Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
function updateIDs {
usermod -u $UID borg
groupmod -g $GID borg
usermod -g $GID borg
chown -R borg:borg /backup
}
function writeAuthKeys {
mkdir -p /home/borg/.ssh/
cd /home/borg/.ssh/
borg-gen-auth-keys /backup/config/hosts.json > authorized_keys
chown -R borg:borg .
chmod 700 .
chmod 700 ..
chmod 600 authorized_keys
}
updateIDs
writeAuthKeys
ssh-keygen -A
exec /bin/s6-svscan /etc/s6.d