From 5a36bfc267de8aff783b5cc31ab8df4ca1d3971d Mon Sep 17 00:00:00 2001 From: Ian Foster Date: Fri, 20 May 2016 13:40:28 -0700 Subject: [PATCH] Updated Dockerfile --- docker/Dockerfile | 56 +++++++++++++++++++++++++++++-------------- docker/realms-wiki.sh | 34 -------------------------- 2 files changed, 38 insertions(+), 52 deletions(-) delete mode 100644 docker/realms-wiki.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 6b4be36..f805e2d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,28 +1,48 @@ -FROM realms/base +FROM ubuntu:trusty -# Packages -RUN apt-get update && apt-get install -y build-essential python-pip python-virtualenv python-dev zlib1g-dev libffi-dev libyaml-dev libldap2-dev libsasl2-dev +RUN apt-get update +RUN apt-get install -y software-properties-common python-software-properties python-pip python-dev libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libyaml-dev libssl-dev libsasl2-dev libldap2-dev npm git python-virtualenv && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# lxml deps -# libxml2-dev libxslt1-dev +RUN ln -s /usr/bin/nodejs /usr/bin/node && \ + npm install -g bower -# Virtualenv -RUN virtualenv /home/deploy/realms-wiki/.venv +RUN useradd -ms /bin/bash wiki -RUN cd /home/deploy/realms-wiki && .venv/bin/pip install realms-wiki +USER wiki -# Logging -RUN mkdir /var/log/realms-wiki && chown deploy.deploy /var/log/realms-wiki +RUN git clone https://github.com/scragg0x/realms-wiki /home/wiki/realms-wiki -# Upstart -RUN mkdir /etc/service/realms-wiki -ADD realms-wiki.sh /etc/service/realms-wiki/run -RUN chmod +x /etc/service/realms-wiki/run +WORKDIR /home/wiki/realms-wiki -# Clear some fat -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN virtualenv .venv && \ + . .venv/bin/activate && \ + pip install -r requirements.txt -# Hand over to deploy user -RUN chown -R deploy.deploy /home/deploy +RUN bower install + +ENV WORKERS=3 +ENV GEVENT_RESOLVER=ares + +ENV REALMS_ENV=docker +ENV REALMS_WIKI_PATH=/home/wiki/data/repo +ENV REALMS_DB_URI='sqlite:////home/wiki/data/wiki.db' +ENV REALMS_SQLALCHEMY_DATABASE_URI=${REALMS_DB_URI} + +RUN mkdir /home/wiki/data && touch /home/wiki/data/.a +VOLUME /home/wiki/data EXPOSE 5000 + +CMD . .venv/bin/activate && \ + gunicorn \ + --name realms-wiki \ + --access-logfile - \ + --error-logfile - \ + --worker-class gevent \ + --workers ${WORKERS} \ + --bind 0.0.0.0:5000 \ + --chdir /home/wiki/realms-wiki \ + 'realms:create_app()' + diff --git a/docker/realms-wiki.sh b/docker/realms-wiki.sh deleted file mode 100644 index 2726bcd..0000000 --- a/docker/realms-wiki.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -PATH=/home/deploy/realms-wiki/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH -export PATH - -LC_ALL=en_US.UTF-8 -GEVENT_RESOLVER=ares - -export LC_ALL -export GEVENT_RESOLVER - -if [ "${REALMS_WIKI_CONFIG}" != "" ]; then - realms-wiki configure "${REALMS_WIKI_CONFIG}" -fi - -if [ "${REALMS_WIKI_WORKERS}" == "" ]; then - REALMS_WIKI_WORKERS=3 -fi - -if [ "${REALMS_WIKI_PORT}" == "" ]; then - REALMS_WIKI_PORT=5000 -fi - -exec gunicorn \ - --name realms-wiki \ - --access-logfile - \ - --error-logfile - \ - --worker-class gevent \ - --workers ${REALMS_WIKI_WORKERS} \ - --bind 0.0.0.0:${REALMS_WIKI_PORT} \ - --user deploy \ - --group deploy \ - --chdir /home/deploy/realms-wiki \ - 'realms:create_app()' >>/var/log/realms-wiki/realms-wiki.log 2>&1