From 7c58540409d420d3c4fa971ffbf0f2ed895032b9 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Fri, 16 Apr 2021 18:32:06 +0000 Subject: [PATCH] Create a testing docker image --- .dockerignore | 16 +++++++++++ README.md | 6 +++++ docker/build.sh | 16 +++++++++++ docker/test-server/Dockerfile | 38 +++++++++++++++++++++++++++ docker/test-server/entrypoint.sh | 6 +++++ docker/test-server/etebase-server.ini | 12 +++++++++ 6 files changed, 94 insertions(+) create mode 100644 .dockerignore create mode 100755 docker/build.sh create mode 100644 docker/test-server/Dockerfile create mode 100644 docker/test-server/entrypoint.sh create mode 100644 docker/test-server/etebase-server.ini diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cd05353 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +/db.sqlite3* +Session.vim +/local_settings.py +.venv +/assets +/logs +/.coverage +/tmp +/media + +__pycache__ +.*.swp + +/.* + +/sandbox diff --git a/README.md b/README.md index 1d39872..7a7efac 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,12 @@ Here are the update steps: 4. Run the migration tool to migrate all of your data. 5. Add your new EteSync 2.0 accounts to all of your devices. +# Testing + +Docker images named `etesync/test-server:` and `:latest` are available for testing etesync clients. +This docker image starts a server on port 3735 that supports user signup (without email confirmation), is in debug mode (thus supporting the reset endpoint), and stores its data locally. +It is in no way suitable for production usage, but is able to start up quickly and makes a good component of CI for etesync clients and users of those clients. + # License Etebase is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License version 3 as published by the Free Software Foundation. See the [LICENSE](./LICENSE) for more information. diff --git a/docker/build.sh b/docker/build.sh new file mode 100755 index 0000000..b8e97cc --- /dev/null +++ b/docker/build.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +# Build the `test-server` image, which runs the server in a simple configuration +# designed to be used in tests, based on the current git revision. + +TAG="${1:-latest}" + +echo "Building working copy to etesync/test-server:${TAG}" + +ETESYNC_VERSION=$(git describe --tags) + +docker build \ + --build-arg ETESYNC_VERSION=${ETESYNC_VERSION} \ + -t etesync/test-server:${TAG} \ + -f docker/test-server/Dockerfile \ + . diff --git a/docker/test-server/Dockerfile b/docker/test-server/Dockerfile new file mode 100644 index 0000000..19ddb91 --- /dev/null +++ b/docker/test-server/Dockerfile @@ -0,0 +1,38 @@ +FROM python:3.9.0-alpine + +ARG ETESYNC_VERSION + +ENV PIP_DISABLE_PIP_VERSION_CHECK=1 +ENV PIP_NO_CACHE_DIR=1 + +# install packages and pip requirements first, in a single step, +COPY /requirements.txt /requirements.txt +RUN set -ex ;\ + apk add libpq postgresql-dev --virtual .build-deps coreutils gcc libc-dev libffi-dev make ;\ + pip install -U pip ;\ + pip install --no-cache-dir --progress-bar off -r /requirements.txt ;\ + apk del .build-deps make gcc coreutils ;\ + rm -rf /root/.cache + +COPY . /app + +RUN set -ex ;\ + mkdir -p /data/static /data/media ;\ + cd /app ;\ + mkdir -p /etc/etebase-server ;\ + cp docker/test-server/etebase-server.ini /etc/etebase-server ;\ + sed -e '/ETEBASE_CREATE_USER_FUNC/ s/^#*/#/' -i /app/etebase_server/settings.py ;\ + chmod +x docker/test-server/entrypoint.sh + +# this is a test image and should start up quickly, so it starts with the DB +# and static data already fully set up. +RUN set -ex ;\ + cd /app ;\ + python manage.py migrate ;\ + python manage.py collectstatic --noinput + +ENV ETESYNC_VERSION=${ETESYNC_VERSION} +VOLUME /data +EXPOSE 3735 + +ENTRYPOINT ["/app/docker/test-server/entrypoint.sh"] diff --git a/docker/test-server/entrypoint.sh b/docker/test-server/entrypoint.sh new file mode 100644 index 0000000..27b7fff --- /dev/null +++ b/docker/test-server/entrypoint.sh @@ -0,0 +1,6 @@ +#! /bin/sh + +echo "Running etesync test server ${ETESYNC_VERSION}" + +cd /app +uvicorn etebase_server.asgi:application --host 0.0.0.0 --port 3735 diff --git a/docker/test-server/etebase-server.ini b/docker/test-server/etebase-server.ini new file mode 100644 index 0000000..a9b65ff --- /dev/null +++ b/docker/test-server/etebase-server.ini @@ -0,0 +1,12 @@ +[global] +secret_file = secret.txt +debug = true +static_root = /data/static +media_root = /data/media + +[allowed_hosts] +allowed_host1 = * + +[database] +engine = django.db.backends.sqlite3 +name = /db.sqlite3