From 88008ad40b2b532c52213859f3a6bfda7d2b33c5 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Thu, 13 Sep 2018 10:38:58 +0200 Subject: [PATCH] LXCize CTS build --- cts/Dockerfile | 40 --------------- cts/{docker => lxc}/etc/nginx/nginx.conf | 0 .../etc/services.d/.s6-svscan/finish | 0 cts/{docker => lxc}/etc/services.d/cts/run | 0 cts/{docker => lxc}/etc/services.d/nginx/run | 0 cts/lxcfile | 49 +++++++++++++++++++ cts/{build.sh => setup.sh} | 0 cts/{ => setup}/adminpwd.sql | 0 cts/{ => setup}/createdb.sql | 0 cts/{ => setup}/etc/init.d/cts | 0 cts/{ => setup}/srv/cts/conf/spotter.py | 0 11 files changed, 49 insertions(+), 40 deletions(-) delete mode 100644 cts/Dockerfile rename cts/{docker => lxc}/etc/nginx/nginx.conf (100%) rename cts/{docker => lxc}/etc/services.d/.s6-svscan/finish (100%) rename cts/{docker => lxc}/etc/services.d/cts/run (100%) rename cts/{docker => lxc}/etc/services.d/nginx/run (100%) create mode 100644 cts/lxcfile rename cts/{build.sh => setup.sh} (100%) rename cts/{ => setup}/adminpwd.sql (100%) rename cts/{ => setup}/createdb.sql (100%) rename cts/{ => setup}/etc/init.d/cts (100%) rename cts/{ => setup}/srv/cts/conf/spotter.py (100%) diff --git a/cts/Dockerfile b/cts/Dockerfile deleted file mode 100644 index 1f346b3..0000000 --- a/cts/Dockerfile +++ /dev/null @@ -1,40 +0,0 @@ -FROM python2 -LABEL maintainer="Disassembler " - -RUN \ - # Add edge/testing repository - echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories \ - # Install runtime dependencies - && apk --no-cache add geos@edge libpq nginx zlib - -RUN \ - # Install build dependencies - apk --no-cache add --virtual .deps build-base git postgresql-dev python2-dev py2-pip zlib-dev \ - # Install CTS - && git clone --depth 1 https://github.com/theirc/CTS /srv/cts \ - && pip install -r /srv/cts/requirements/production.txt \ - # Hackfix geos version detection - && sed -i 's/\$//' /usr/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py \ - # Make manage.py globally executable - && chmod +x /srv/cts/manage.py \ - && ln -s /srv/cts/manage.py /usr/local/bin/manage.py \ - # Compile static files - && sed -i '/debug_toolbar/d' /srv/cts/cts/settings/dev.py \ - && DJANGO_SETTINGS_MODULE=cts.settings.dev manage.py collectstatic -l --noinput \ - # Create OS user - && addgroup -S -g 8006 cts \ - && adduser -S -u 8006 -h /srv/cts -s /bin/false -g cts -G cts cts \ - && chown -R cts:cts /srv/cts \ - # Cleanup - && apk --no-cache del .deps \ - && find /srv/cts -name '.git*' -exec rm -rf {} + \ - && rm -rf /root/.cache - -COPY docker/ / - -VOLUME ["/srv/cts/cts/settings"] -EXPOSE 8080 - -ENV DJANGO_SETTINGS_MODULE cts.settings.spotter -WORKDIR /srv/cts -CMD ["s6-svscan", "/etc/services.d"] diff --git a/cts/docker/etc/nginx/nginx.conf b/cts/lxc/etc/nginx/nginx.conf similarity index 100% rename from cts/docker/etc/nginx/nginx.conf rename to cts/lxc/etc/nginx/nginx.conf diff --git a/cts/docker/etc/services.d/.s6-svscan/finish b/cts/lxc/etc/services.d/.s6-svscan/finish similarity index 100% rename from cts/docker/etc/services.d/.s6-svscan/finish rename to cts/lxc/etc/services.d/.s6-svscan/finish diff --git a/cts/docker/etc/services.d/cts/run b/cts/lxc/etc/services.d/cts/run similarity index 100% rename from cts/docker/etc/services.d/cts/run rename to cts/lxc/etc/services.d/cts/run diff --git a/cts/docker/etc/services.d/nginx/run b/cts/lxc/etc/services.d/nginx/run similarity index 100% rename from cts/docker/etc/services.d/nginx/run rename to cts/lxc/etc/services.d/nginx/run diff --git a/cts/lxcfile b/cts/lxcfile new file mode 100644 index 0000000..2edef5e --- /dev/null +++ b/cts/lxcfile @@ -0,0 +1,49 @@ +IMAGE cts +LAYER shared/alpine +LAYER shared/libxml +LAYER shared/python2 +LAYER cts/cts + +RUN EOF + # Add edge/testing repository + echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >>/etc/apk/repositories + + # Install runtime dependencies + apk --no-cache add geos@edge libpq nginx zlib + + # Install build dependencies + apk --no-cache add --virtual .deps build-base git postgresql-dev python2-dev py2-pip zlib-dev + + # Install CTS + git clone --depth 1 https://github.com/theirc/CTS /srv/cts + pip install -r /srv/cts/requirements/production.txt + + # Hackfix geos version detection + sed -i 's/\$//' /usr/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py + + # Make manage.py globally executable + chmod +x /srv/cts/manage.py + ln -s /srv/cts/manage.py /usr/local/bin/manage.py + + # Compile static files + sed -i '/debug_toolbar/d' /srv/cts/cts/settings/dev.py + DJANGO_SETTINGS_MODULE=cts.settings.dev manage.py collectstatic -l --noinput + + # Create OS user + addgroup -S -g 8006 cts + adduser -S -u 8006 -h /srv/cts -s /bin/false -g cts -G cts cts + chown -R cts:cts /srv/cts + + # Cleanup + apk --no-cache del .deps + find /srv/cts -name '.git*' -exec rm -rf {} + + rm -rf /root/.cache +EOF + +COPY lxc + +MOUNT /srv/cts/conf srv/cts/cts/settings + +ENV DJANGO_SETTINGS_MODULE cts.settings.spotter +WORKDIR /srv/cts +CMD /bin/s6-svscan /etc/services.d diff --git a/cts/build.sh b/cts/setup.sh similarity index 100% rename from cts/build.sh rename to cts/setup.sh diff --git a/cts/adminpwd.sql b/cts/setup/adminpwd.sql similarity index 100% rename from cts/adminpwd.sql rename to cts/setup/adminpwd.sql diff --git a/cts/createdb.sql b/cts/setup/createdb.sql similarity index 100% rename from cts/createdb.sql rename to cts/setup/createdb.sql diff --git a/cts/etc/init.d/cts b/cts/setup/etc/init.d/cts similarity index 100% rename from cts/etc/init.d/cts rename to cts/setup/etc/init.d/cts diff --git a/cts/srv/cts/conf/spotter.py b/cts/setup/srv/cts/conf/spotter.py similarity index 100% rename from cts/srv/cts/conf/spotter.py rename to cts/setup/srv/cts/conf/spotter.py