From b72f5847dac0d111fc7d4cad6cf1181cf561a436 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Wed, 4 Mar 2020 18:32:39 +0100 Subject: [PATCH] Add Docker setup for lightweight local testing --- .gitignore | 1 + Dockerfile | 51 ++++++++++++++++++++++++++++++++++++++++++++++ docs/changelog.rst | 1 + docs/conf.py | 3 ++- gvapgsql.sh | 7 +++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100755 gvapgsql.sh diff --git a/.gitignore b/.gitignore index da9d74b..844016f 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ _build/ *.sqlite3 .idea/ .vagrant/ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cca69c4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +ARG DEBIAN_RELEASE=buster +FROM debian:$DEBIAN_RELEASE +LABEL maintainer="Jan Dittberner " + +ENV LC_ALL=C.UTF-8 +ENV LANG=C.UTF-8 + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ + dumb-init \ + gettext \ + git \ + python3-dev \ + python3-pip \ + python3-setuptools \ + python3-virtualenv \ + python3-wheel \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*.* + +RUN python3 -m pip install --prefix=/usr/local pipenv + +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + libpq-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/*.* + +ARG GVAGID=2000 +ARG GVAUID=2000 + +ARG GVAAPP=gvapgsql + +WORKDIR /srv/$GVAAPP + +COPY Pipfile Pipfile.lock /srv/$GVAAPP/ + +RUN addgroup --gid $GVAGID $GVAAPP ; \ + adduser --home /home/$GVAAPP --shell /bin/bash --uid $GVAUID --gid $GVAGID --disabled-password --gecos "User for gnuviechadmin component $GVAAPP" $GVAAPP + +USER $GVAAPP +RUN python3 -m virtualenv --python=python3 /home/$GVAAPP/$GVAAPP-venv ; \ + /home/$GVAAPP/$GVAAPP-venv/bin/python3 -m pip install -U pip ; \ + VIRTUAL_ENV=/home/$GVAAPP/$GVAAPP-venv pipenv install --deploy --ignore-pipfile --dev + +VOLUME /srv/$GVAAPP + +COPY gvapgsql.sh /srv/ + +ENTRYPOINT ["dumb-init", "/srv/gvapgsql.sh"] diff --git a/docs/changelog.rst b/docs/changelog.rst index 675df65..7aa1274 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,7 @@ Changelog ========= +* :support:`-` add Docker setup for lightweight local testing * :support:`-` update Vagrant setup to libvirt and Debian Buster * :support:`-` move pgsqltasks to top level to keep the task names when using Python 3 diff --git a/docs/conf.py b/docs/conf.py index 4b0766f..8b05e6b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,6 +21,7 @@ import os sys.path.insert(0, os.path.abspath(os.path.join('..', 'gvapgsql'))) os.environ['GVAPGSQL_BROKER_URL'] = 'amqp://localhost' +os.environ['GVAPGSQL_RESULTS_REDIS_URL'] = 'redis://' os.environ['GVAPGSQL_DBADMIN_HOST'] = 'localhost' os.environ['GVAPGSQL_DBADMIN_PORT'] = '5432' os.environ['GVAPGSQL_DBADMIN_USER'] = 'gvapgsql' @@ -37,7 +38,7 @@ extensions = ['releases', 'sphinx.ext.autodoc', 'celery.contrib.sphinx'] # configuration for releases extension releases_issue_uri = 'https://git.dittberner.info/gnuviech/gvapgsql/issues/%s' -releases_release_uri = 'https://git.dittberner.info/gnuviech/gvapgsql/stc/tag/%s' +releases_release_uri = 'https://git.dittberner.info/gnuviech/gvapgsql/src/tag/%s' # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/gvapgsql.sh b/gvapgsql.sh new file mode 100755 index 0000000..d28d7b8 --- /dev/null +++ b/gvapgsql.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +. /home/gvapgsql/gvapgsql-venv/bin/activate +cd /srv/gvapgsql/gvapgsql +celery -A pgsqltasks worker -Q pgsql -l info