Initial commit
This commit is contained in:
commit
efac43bfbb
46
Dockerfile
Normal file
46
Dockerfile
Normal 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
2
root/etc/s6.d/sshd/run
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
/usr/sbin/sshd -D -d
|
22
root/usr/local/bin/run.sh
Executable file
22
root/usr/local/bin/run.sh
Executable 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
|
Loading…
Reference in a new issue