diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..45c6d6469 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +.git +.github +.env +.mypy_cache +.pytest_cache +.vscode +*.egg-info +__pycache__ +dist +env +node_modules +client +e2e/node_modules +e2e/server/env +server/env + diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml new file mode 100644 index 000000000..7c2ae3daf --- /dev/null +++ b/e2e/docker-compose.yml @@ -0,0 +1,55 @@ +version: "3.8" + +services: + elastic: + image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2 + environment: + - discovery.type=single-node + networks: + - e2e + tmpfs: + - /usr/share/elasticsearch/data + + redis: + image: redis:alpine + networks: + - e2e + + mongo: + image: mongo:4 + networks: + - e2e + tmpfs: + - /data/db + + server: + build: + context: ../ + dockerfile: e2e/server/Dockerfile + ports: + - "5000:5000" + networks: + - e2e + depends_on: + - redis + - mongo + - elastic + environment: + - WEB_CONCURRENCY=2 + - WEBPACK_MANIFEST_PATH=/opt/client-dist/manifest.json + - MONGO_URI=mongodb://mongo/superdesk + - ARCHIVED_MONGO_URI=mongodb://mongo/superdesk + - CONTENTAPI_MONGO_URI=mongodb://mongo/superdesk_capi + - PUBLICAPI_MONGO_URI=mongodb://mongo/superdesk_papi + - LEGAL_ARCHIVE_URI=mongodb://mongo/superdesk_legal + - ARCHIVED_URI=mongodb://mongo/superdesk_archive + - ELASTICSEARCH_URL=http://elastic:9200 + - ELASTICSEARCH_INDEX=superdesk_e2e + - CELERY_BROKER_URL=redis://redis:6379/1 + - REDIS_URL=redis://redis:6379/1 + - DEFAULT_TIMEZONE=Europe/Prague + - SECRET_KEY=e2e + +networks: + e2e: + driver: bridge diff --git a/e2e/server/Dockerfile b/e2e/server/Dockerfile new file mode 100644 index 000000000..dc7feea11 --- /dev/null +++ b/e2e/server/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ +python3 python3-dev python3-pip python3-venv git gcc curl \ +# lxml +libxml2-dev libxslt-dev \ +# PIL +libjpeg-dev zlib1g-dev \ +# magic +libmagic-dev \ +&& rm -rf /var/lib/apt/lists/* + +# setup venv +ENV VIRTUAL_ENV=/opt/venv +RUN python3 -m venv "$VIRTUAL_ENV" +ENV PATH="$VIRTUAL_ENV/bin:$PATH" + +ENV PYTHONUNBUFFERED=1 +ENV C_FORCE_ROOT=False +ENV CELERYBEAT_SCHEDULE_FILENAME=/tmp/celerybeatschedule.db +ENV TZ=Europe/London + +# update venv +RUN python3 -m pip install -U pip wheel setuptools + +# install core requirements +WORKDIR /tmp +COPY e2e/server/core-requirements.txt . +RUN python3 -m pip install -Ur core-requirements.txt + +# install server +WORKDIR /opt/superdesk/ +COPY . . + +# go to e2e server +WORKDIR /opt/superdesk/e2e/server + +RUN python3 -m pip install -Ur requirements.txt + +ENTRYPOINT [ "/opt/superdesk/e2e/server/docker/start.sh" ] +CMD ["honcho", "start"] diff --git a/e2e/server/core-requirements.txt b/e2e/server/core-requirements.txt new file mode 100644 index 000000000..3ff429e1d --- /dev/null +++ b/e2e/server/core-requirements.txt @@ -0,0 +1,3 @@ +gunicorn==19.7.1 +honcho==1.0.1 +git+https://github.com/superdesk/superdesk-core.git@develop#egg=superdesk-core \ No newline at end of file diff --git a/e2e/server/docker/start.sh b/e2e/server/docker/start.sh new file mode 100755 index 000000000..183d5db58 --- /dev/null +++ b/e2e/server/docker/start.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +cd /opt/superdesk/e2e/server + +# wait for elastic to be up +printf 'waiting for elastic.' +until $(curl --output /dev/null --silent --head --fail "${ELASTICSEARCH_URL}"); do + printf '.' + sleep .5 +done +echo 'done.' + +# init dbs +honcho run python3 manage.py app:initialize_data + +exec "$@" diff --git a/e2e/server/requirements.txt b/e2e/server/requirements.txt index bab4f33af..1f9fc9a0d 100644 --- a/e2e/server/requirements.txt +++ b/e2e/server/requirements.txt @@ -1,4 +1,2 @@ -gunicorn==19.7.1 -honcho==1.0.1 -git+https://github.com/superdesk/superdesk-core.git@develop#egg=superdesk-core --e ../../ +-r ./core-requirements.txt +-e ../../ \ No newline at end of file diff --git a/e2e/server/settings.py b/e2e/server/settings.py index 8701dfcd8..c8e0cb157 100644 --- a/e2e/server/settings.py +++ b/e2e/server/settings.py @@ -1,18 +1,6 @@ import os from pathlib import Path -from superdesk.default_settings import INSTALLED_APPS, SECRET_KEY - - -def env(variable, fallback_value=None): - env_value = os.environ.get(variable, '') - if len(env_value) == 0: - return fallback_value - else: - if env_value == "__EMPTY__": - return '' - else: - return env_value - +from superdesk.default_settings import INSTALLED_APPS, SECRET_KEY, env ABS_PATH = str(Path(__file__).resolve().parent) @@ -31,17 +19,6 @@ def env(variable, fallback_value=None): 'force_unlock_item', ]) -RENDITIONS = { - 'picture': { - 'thumbnail': {'width': 220, 'height': 120}, - 'viewImage': {'width': 640, 'height': 640}, - 'baseImage': {'width': 1400, 'height': 1400}, - }, - 'avatar': { - 'thumbnail': {'width': 60, 'height': 60}, - 'viewImage': {'width': 200, 'height': 200}, - } -} WS_HOST = env('WSHOST', '0.0.0.0') WS_PORT = env('WSPORT', '5100') @@ -49,15 +26,13 @@ def env(variable, fallback_value=None): LOG_CONFIG_FILE = env('LOG_CONFIG_FILE', 'logging_config.yml') REDIS_URL = env('REDIS_URL', 'redis://localhost:6379') -if env('REDIS_PORT'): - REDIS_URL = env('REDIS_PORT').replace('tcp:', 'redis:') BROKER_URL = env('CELERY_BROKER_URL', REDIS_URL) MONGO_DBNAME = 'e2e_superdesk' -MONGO_URI = 'mongodb://localhost/%s' % MONGO_DBNAME +MONGO_URI = os.environ.get("MONGO_URI", 'mongodb://localhost/%s' % MONGO_DBNAME) ARCHIVED_DBNAME = 'e2e_archived' -ARCHIVED_URI = 'mongodb://localhost/%s' % ARCHIVED_DBNAME +ARCHIVED_URI = os.environ.get("ARCHIVED_MONGO_URI", 'mongodb://localhost/%s' % ARCHIVED_DBNAME) LEGAL_ARCHIVE = False CONTENTAPI_ENABLED = False