Add Dockerfile
Change-Id: Ia316144ab80d9a60c640eb4ee0a4b723bc5f344d
Related-PROD: PROD-30051
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..b83712c
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,5 @@
+# .dockerignore
+.git
+Dockerfile
+.dockerignore
+run-*.sh
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..91fdcb1
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,25 @@
+FROM ubuntu:xenial
+
+WORKDIR /app
+
+# explicitly set user/group IDs
+RUN groupadd -r -g 999 sfnotifier && \
+ useradd -r -g sfnotifier -u 999 -m -s /sbin/nologin -d /app -c "sf-notifier user" sfnotifier
+
+# Install system requirements
+RUN apt-get update -qq && apt-get upgrade -y && \
+ apt-get install --no-install-recommends -y -q \
+ build-essential \
+ python2.7 \
+ python2.7-dev \
+ python-pip \
+ python-wheel \
+ python-setuptools \
+ curl git && \
+ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+COPY requirements.txt ./
+RUN pip install -r /app/requirements.txt
+
+COPY . .
+CMD ./entrypoint.sh
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100755
index 0000000..fbeb6ac
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+export SIMPLE_SETTINGS=${SIMPLE_SETTINGS:-sf_notifier.settings.production}
+export SF_NOTIFIER_ALERT_ID_HASH_FUNC=${SF_NOTIFIER_ALERT_ID_HASH_FUNC:-sha256}
+
+WORKERS=${SF_NOTIFIER_WORKERS:-4}
+BUFFER=${SF_NOTIFIER_BUFFER_SIZE:-32768}
+PORT=${SF_NOTIFIER_APP_PORT:-5000}
+CACHE_ITEMS=${SF_NOTIFIER_CACHE_ITEMS:-300}
+CACHE_FILE=${SF_NOTIFIER_CACHE_FILE:-/tmp/cachefile}
+
+mkdir -p /var/log/sf-notifier
+chown -R 999:999 /var/log/sf-notifier
+
+MULES=$(for _ in $(seq 1 $WORKERS); do
+ echo "--mule "
+done)
+
+uwsgi -p 4 \
+ --uid 999 \
+ --gid 999 \
+ --http 0.0.0.0:${PORT} \
+ --wsgi-file sf_notifier/server.py \
+ --callable app_dispatch \
+ --buffer-size=${BUFFER} \
+ --max-worker-lifetime 300 \
+ --cache2 name=mycache,items=${CACHE_ITEMS},store=${CACHE_FILE},store_sync=10 \
+ ${MULES} \
+ --master