aboutsummaryrefslogtreecommitdiff
path: root/unifi-video/Dockerfile
blob: ae584b0fba50ba240f3c21221d879f58f5e473d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
FROM frolvlad/alpine-java:jre8-slim
LABEL maintainer="Mike Crute <mike@crute.us>"

ARG dl_url

ADD lsb_release /usr/bin
ADD log4j2.json /tmp

RUN \
    # Validate required arguments were passed
    test -z "${dl_url}"       && { echo -e "\033[31mMissing build parameter 'dl_url'\033[39m"; exit 1; }; \
    \
    # Install build and run dependencies
    apk add --no-cache --virtual .build-deps \
        binutils \
        ca-certificates \
        curl \
    && apk add --no-cache \
        dumb-init \
        libcap \
        mongodb \
        su-exec \
    \
    # Fetch the Unifi package
    && cd /tmp \
    && curl -s -o unifi_video.deb "${dl_url}" \
    \
    # Unpack the debian package and "install" it
    && ar x unifi_video.deb \
    && mkdir debian \
    && tar -C debian -xzf control.tar.gz \
    && tar -xzf data.tar.gz \
    && rm -rf usr/share usr/sbin \
    && mv usr/lib/unifi-video /usr/lib \
    \
    # Create directories and link everything together
    && mkdir -p /var/lib/unifi-video /var/log/unifi-video /var/run/unifi-video \
    && ln -sf /usr/bin/mongod /usr/lib/unifi-video/bin/mongod \
    && ln -sf /var/lib/unifi-video /usr/lib/unifi-video/data \
    && ln -sf /var/log/unifi-video /usr/lib/unifi-video/logs \
    && ln -sf /var/run/unifi-video /usr/lib/unifi-video/run \
    \
    # Create Tomcat directories
    && mkdir -p /usr/lib/unifi-video/conf/Catalina \
    && mkdir -p /usr/lib/unifi-video/work \
    \
    # Write out version file
    && VERSIG=$(awk '/^VERSIG/ { split($1, a, "="); print a[2]; }' debian/postinst) \
    && echo "NVR.x86_64.${VERSIG}" > /etc/discovery.version \
    \
    # Install our customizations
    && mv /tmp/log4j2.json /usr/lib/unifi-video \
    \
    # Cleanup
    && apk del .build-deps \
    && rm -rf /tmp/*

ADD entrypoint.sh /

STOPSIGNAL SIGTERM
ENTRYPOINT [ "/entrypoint.sh" ]