From 7df117e3744e606341f1772cf3bde189e80fca12 Mon Sep 17 00:00:00 2001
From: Tom Downes <tpdownes@gmail.com>
Date: Mon, 18 Feb 2019 16:03:47 -0600
Subject: [PATCH] Explicitly set LVAalert Overseer Resource to randomized
 string

---
 Dockerfile                               | 5 ++++-
 docker/entrypoint                        | 4 ++++
 docker/supervisord-lvalert-overseer.conf | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 docker/entrypoint

diff --git a/Dockerfile b/Dockerfile
index 16482bc05..7bcb1f81e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -34,6 +34,7 @@ RUN apt-get update && \
     apt-get clean && \
     npm install -g bower
 
+COPY docker/entrypoint /usr/local/bin/entrypoint
 COPY docker/supervisord.conf /etc/supervisor/supervisord.conf
 COPY docker/supervisord-apache2.conf /etc/supervisor/conf.d/apache2.conf
 COPY docker/supervisord-lvalert-overseer.conf /etc/supervisor/conf.d/overseer.conf
@@ -92,9 +93,11 @@ RUN useradd -M -u 50001 -g www-data -s /bin/false gracedb
 
 # set secure file/directory permissions. In particular, ADD command at
 # beginning of recipe inherits umask of user running the build
-RUN chown gracedb:www-data /app/logs /app/project_data && \
+RUN chmod 0755 /usr/local/bin/entrypoint && \
+    chown gracedb:www-data /app/logs /app/project_data && \
     chmod 0750 /app/logs /app/project_data && \
     find /app/gracedb_project -type d -exec chmod 0755 {} + && \
     find /app/gracedb_project -type f -exec chmod 0644 {} +
 
+ENTRYPOINT [ "/usr/local/bin/entrypoint" ]
 CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]
diff --git a/docker/entrypoint b/docker/entrypoint
new file mode 100644
index 000000000..9d8be7681
--- /dev/null
+++ b/docker/entrypoint
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+export LVALERT_OVERSEER_RESOURCE=${LVALERT_USER}_overseer_$(python  -c 'import uuid; print(uuid.uuid4().hex)')
+exec "$@"
diff --git a/docker/supervisord-lvalert-overseer.conf b/docker/supervisord-lvalert-overseer.conf
index 9074247aa..e3cf75740 100644
--- a/docker/supervisord-lvalert-overseer.conf
+++ b/docker/supervisord-lvalert-overseer.conf
@@ -1,6 +1,7 @@
 [program:overseer]
 command=lvalert_overseer -a %(ENV_LVALERT_USER)s -b %(ENV_LVALERT_PASSWORD)s
     -s %(ENV_LVALERT_SERVER)s -p %(ENV_LVALERT_OVERSEER_PORT)s
+    -r %(ENV_LVALERT_OVERSEER_RESOURCE)s
     -l /tmp/overseer_stdout.log -e /tmp/overseer_stderr.log
 user=gracedb
 group=www-data
-- 
GitLab