From 0b3f1ae822d7fe198710a5d27bfcff87fad51453 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Sun, 20 Dec 2020 17:30:22 +0100 Subject: [PATCH 1/4] config: Read Redis URL from environment variables if available --- config/default.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/default.py b/config/default.py index 5cf7e572a6..66c276f019 100644 --- a/config/default.py +++ b/config/default.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import os import os.path here = os.path.abspath(os.path.dirname(__file__)) @@ -44,8 +45,8 @@ SKYLINES_MAP_TILE_URL = "https://www.skylines.aero/mapproxy" -BROKER_URL = "redis://localhost:6379/0" -CELERY_RESULT_BACKEND = "redis://localhost:6379/0" +BROKER_URL = os.getenv("REDIS_URL", "redis://localhost:6379/0") +CELERY_RESULT_BACKEND = os.getenv("REDIS_URL", "redis://localhost:6379/0") CELERYD_LOG_LEVEL = "INFO" # limits for AnalyseFlight From 978ddf7317a58b8fbc146a2fc9fb21e8147656f0 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 21 Dec 2020 10:07:59 +0100 Subject: [PATCH 2/4] Add .dockerignore file --- .dockerignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..d2e5f56736 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.cache/ +.coverage +.envrc +.git/ +.github/ +.idea/ +.local/ +.vagrant/ +ember/node_modules/ +htdocs/ From 4478dabe2d6b7c319af12a7545f633ab2e8a6f39 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 21 Dec 2020 10:28:52 +0100 Subject: [PATCH 3/4] Add basic Docker setup --- Dockerfile | 16 ++++++++++++++++ docker-compose.yml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..3ea795b08c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +# Use Python 2.7 by default, but allow +# e.g. `--build-arg PYTHON_VERSION=3.6` usage +ARG PYTHON_VERSION=2.7 +FROM python:${PYTHON_VERSION} + +RUN pip install --upgrade pip +RUN pip install pipenv==v2020.11.15 + +WORKDIR /home/skylines/code/ + +# Install Python dependencies +COPY Pipfile Pipfile.lock /home/skylines/code/ +RUN pipenv install --dev --python=${PYTHON_VERSION} + +# Run the development server by default +CMD ["pipenv", "run", "./manage.py", "runserver"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..105153b1ca --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,44 @@ +version: '3.9' + +volumes: + postgres_data: + +services: + db: + image: postgis/postgis:10-2.5 + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + POSTGRES_DB: skylines_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - 5432:5432 + healthcheck: + test: pg_isready -U postgres + interval: 5s + + redis: + image: redis + ports: + - 6379:6379 + healthcheck: + test: redis-cli ping + interval: 5s + + api: + build: . + environment: + PGHOST: db + PGUSER: postgres + PGPASSWORD: postgres + REDIS_URL: redis://redis:6379/0 + ports: + - 5000:5000 + volumes: + - .:/home/skylines/code/ + depends_on: + db: + condition: service_healthy + redis: + condition: service_healthy From 939b50e41ff1346bfde68ee79df75f3c85c6b4c2 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Mon, 21 Dec 2020 10:31:25 +0100 Subject: [PATCH 4/4] CI: Use Docker setup --- .github/workflows/ci.yml | 41 +++------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7314739dd1..1a74d9d44e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,49 +74,14 @@ jobs: matrix: python-version: [2.7, 3.6] - services: - postgres: - image: postgis/postgis:10-2.5 - env: - POSTGRES_DB: skylines_test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - # Set health checks to wait until postgres has started - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 6379:6379 - - env: - PGHOST: localhost - PGUSER: postgres - PGPASSWORD: postgres - steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - # Install Python dependencies - - run: pip install pipenv==v2020.4.1b2 - - run: pipenv install --dev + # Build Docker images + - run: docker-compose build --build-arg PYTHON_VERSION=${{ matrix.python-version }} # Run the test suite - - run: pipenv run py.test -vv --color=yes --cov=skylines --cov-report term-missing:skip-covered + - run: docker-compose run api pipenv run py.test -vv --color=yes --cov=skylines --cov-report term-missing:skip-covered backend-lint: name: Backend (Lint)