mirror of
https://github.com/ep1cman/unifi-protect-backup.git
synced 2025-12-05 23:53:30 +00:00
Merge branch 'docker_user' of github.com:ep1cman/unifiprotect-backup into docker_user
This commit is contained in:
53
Dockerfile
53
Dockerfile
@@ -2,34 +2,57 @@
|
||||
# $ poetry build
|
||||
# $ docker build -t ghcr.io/ep1cman/unifi-protect-backup .
|
||||
FROM python:3.9-alpine
|
||||
|
||||
# Install packages
|
||||
RUN apk add shadow gcc musl-dev zlib-dev jpeg-dev rclone
|
||||
|
||||
ENV PUID=1000
|
||||
ENV PGID=1000
|
||||
RUN groupmod -g $PGID users && \
|
||||
useradd --uid $PUID -U -d /app -s /bin/false abc && \
|
||||
# Create user + directories
|
||||
RUN groupmod -g 1000 users && \
|
||||
useradd -u 911 -U -d /config -s /bin/false abc && \
|
||||
usermod -G users abc && \
|
||||
mkdir /config /app && \
|
||||
chown abc /app
|
||||
ENV PATH="/app/.local/bin:${PATH}"
|
||||
USER abc
|
||||
WORKDIR /app
|
||||
mkdir -p \
|
||||
/config \
|
||||
/defaults \
|
||||
/data
|
||||
|
||||
COPY dist/unifi-protect-backup-0.4.0.tar.gz sdist.tar.gz
|
||||
RUN pip install --user sdist.tar.gz
|
||||
COPY misc/docker /
|
||||
|
||||
# Install unifi-protect-backup
|
||||
COPY dist/unifi-protect-backup-0.4.0.tar.gz /tmp/sdist.tar.gz
|
||||
RUN pip install /tmp/sdist.tar.gz && rm /tmp/sdist.tar.gz
|
||||
|
||||
# Settings
|
||||
ENV UFP_USERNAME=unifi_protect_user
|
||||
ENV UFP_PASSWORD=unifi_protect_password
|
||||
ENV UFP_ADDRESS=127.0.0.1
|
||||
ENV UFP_PORT=443
|
||||
ENV UFP_SSL_VERIFY=true
|
||||
ENV RCLONE_RETENTION=7d
|
||||
ENV RCLONE_DESTINATION=my_remote:/unifi_protect_backup
|
||||
ENV RCLONE_DESTINATION=local:/data
|
||||
ENV VERBOSITY="v"
|
||||
ENV TZ=UTC
|
||||
ENV IGNORE_CAMERAS=""
|
||||
ENV RCLONE_CONFIG="/config/rclone.conf"
|
||||
ENV TZ=UTC
|
||||
ENV PUID=1000
|
||||
ENV PGID=1000
|
||||
|
||||
VOLUME [ "/config" ]
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
CMD ["sh", "-c", "unifi-protect-backup -${VERBOSITY}"]
|
||||
# Currently borken because there is no v3 release with support for changing PATH
|
||||
# Setup S6
|
||||
# ARG S6_OVERLAY_VERSION=3.0.0.2-2
|
||||
# ARG S6_OVERLAY_ARCH=x86_64
|
||||
# ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz /tmp
|
||||
# RUN tar -C / -Jxpf /tmp/s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz
|
||||
# ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}-${S6_OVERLAY_VERSION}.tar.xz /tmp
|
||||
# RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64-${S6_OVERLAY_VERSION}.tar.xz
|
||||
# ENV PATH=/command:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# set version for s6 overlay
|
||||
ARG OVERLAY_VERSION="v2.2.0.3"
|
||||
ARG OVERLAY_ARCH="amd64"
|
||||
|
||||
# add s6 overlay
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/
|
||||
RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer
|
||||
ENTRYPOINT ["/init"]
|
||||
2
misc/docker/defaults/rclone.conf
Normal file
2
misc/docker/defaults/rclone.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
[local]
|
||||
type = local
|
||||
8
misc/docker/etc/cont-init.d/01-setup-user
Executable file
8
misc/docker/etc/cont-init.d/01-setup-user
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
echo "[cont-init.d] Setting up user"
|
||||
PUID=${PUID:-911}
|
||||
PGID=${PGID:-911}
|
||||
|
||||
groupmod -o -g "$PGID" abc
|
||||
usermod -o -u "$PUID" abc
|
||||
8
misc/docker/etc/cont-init.d/02-config
Executable file
8
misc/docker/etc/cont-init.d/02-config
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
# default config file
|
||||
[[ ! -f "/config/rclone.conf" ]] && \
|
||||
echo "[cont-init.d] Copying default config"
|
||||
cp \
|
||||
/defaults/rclone.conf \
|
||||
/config/rclone.conf
|
||||
4
misc/docker/etc/cont-init.d/03-permissions
Normal file
4
misc/docker/etc/cont-init.d/03-permissions
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
chown abc:abc /data
|
||||
chown -R abc:abc /config
|
||||
4
misc/docker/etc/services.d/unifi-protect-backup/run
Normal file
4
misc/docker/etc/services.d/unifi-protect-backup/run
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv /bin/sh
|
||||
|
||||
export RCLONE_CONFIG="/config/rclone.conf"
|
||||
s6-setuidgid abc unifi-protect-backup -${VERBOSITY}
|
||||
Reference in New Issue
Block a user