aboutsummaryrefslogtreecommitdiff
path: root/unifi/Dockerfile
blob: b04fd2d38e2c9808b6e3a1806dc0c245de083f16 (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
FROM alpine:edge
LABEL maintainer="Mike Crute <mike@crute.us>"

# TODO: Move all the unpacking stuff to the Makefile

ARG deb_version
ARG checksum

ADD log4j.properties /tmp/

RUN set -euxo pipefail; \
    # Validate required arguments were passed
    test -z "${deb_version}"  && { echo -e "\033[31mMissing build parameter 'deb_version'\033[39m"; exit 1; }; \
    test -z "${checksum}" && { echo -e "\033[31mMissing build parameter 'checksum'\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 \
        java-snappy \
        libcap \
        nss \
        openjdk17-jre-headless \
        su-exec \
    \
    # Fetch the Unifi package and validate the checksum before unpacking
    && cd /tmp \
    && curl -sO "https://dl.ui.com/unifi/${deb_version}/unifi_sysvinit_all.deb" \
    && echo "${checksum} *unifi_sysvinit_all.deb" > checksums.txt \
    && sha256sum -sc checksums.txt \
    \
    # Unpack the debian package and "install" it
    && ar x unifi_sysvinit_all.deb \
    && tar -xJf data.tar.xz \
    && rm usr/lib/unifi/bin/unifi.init \
    && mv usr/lib/unifi /usr/lib \
    \
    # Create directories and link everything together
    && mkdir -p /var/lib/unifi /var/log/unifi /var/run/unifi \
    && ln -sf /usr/bin/mongod /usr/lib/unifi/bin/mongod \
    && ln -sf /var/lib/unifi /usr/lib/unifi/data \
    && ln -sf /var/log/unifi /usr/lib/unifi/logs \
    && ln -sf /var/run/unifi /usr/lib/unifi/run \
    \
    # Install our customizations
    && mv /tmp/log4j.properties /usr/lib/unifi \
    \
    # Cleanup
    && apk del .build-deps \
    && rm -rf /tmp/*

ADD unifi-setup.sh /
ADD simplevisor.json /
ADD simplevisor /

STOPSIGNAL SIGTERM
ENTRYPOINT [ "/simplevisor" ]