Skip to content

Commit

Permalink
add setup for e2e server docker (#1869)
Browse files Browse the repository at this point in the history
to run use:

```bash
$ cd e2e
$ docker-compose build
$ docker-compose up
```
  • Loading branch information
petrjasek authored Oct 23, 2023
1 parent b6c4bdd commit c5e89f0
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 32 deletions.
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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

55 changes: 55 additions & 0 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions e2e/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 3 additions & 0 deletions e2e/server/core-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gunicorn==19.7.1
honcho==1.0.1
git+https://github.com/superdesk/superdesk-core.git@develop#egg=superdesk-core
17 changes: 17 additions & 0 deletions e2e/server/docker/start.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
6 changes: 2 additions & 4 deletions e2e/server/requirements.txt
Original file line number Diff line number Diff line change
@@ -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 ../../
31 changes: 3 additions & 28 deletions e2e/server/settings.py
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -31,33 +19,20 @@ 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')

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
Expand Down

0 comments on commit c5e89f0

Please sign in to comment.