Skip to content

Commit

Permalink
Support custom controller UI/API port for HEALTHCHECK
Browse files Browse the repository at this point in the history
The HEALTHCHECK command hard-codes the default controller UI/API port.
This fails (shows the container status as unhealthy) if the user has
specified a custom port for it in the system properties file.

Make this work correctly in such cases by parsing the port from the file
if it is present and uncommented. In order to avoid a stupidly
complicated one-liner move the healthcheck command into a separate shell
script.
  • Loading branch information
duaneg authored and Duane Griffin committed Oct 13, 2017
1 parent 7995bc7 commit 70ee799
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ RUN mkdir -p /usr/unifi \
/usr/local/unifi/init.d \
/usr/unifi/init.d
COPY docker-entrypoint.sh /usr/local/bin/
COPY docker-healthcheck.sh /usr/local/bin/
COPY functions /usr/unifi/functions
COPY import_cert /usr/unifi/init.d/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
&& chmod +x /usr/unifi/init.d/import_cert

WORKDIR /var/lib/unifi

HEALTHCHECK CMD curl -k -L --fail https://localhost:8443 || exit 1
HEALTHCHECK CMD /usr/local/bin/docker-healthcheck.sh || exit 1

# execute controller using JSVC like original debian package does
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
Expand Down
7 changes: 7 additions & 0 deletions docker-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

SYSPROPS_FILE=${DATADIR}/system.properties
SYSPROPS_PORT=`grep "^unifi.https.port=" ${SYSPROPS_FILE} | cut -d'=' -f2`
PORT=${SYSPROPS_PORT:-8443}

curl -k -L --fail https://localhost:${PORT}

0 comments on commit 70ee799

Please sign in to comment.