Skip to content

Commit

Permalink
Merge pull request #2306 from Turbo87/ci-docker
Browse files Browse the repository at this point in the history
Use `docker-compose` setup to fix CI
  • Loading branch information
Turbo87 authored Dec 21, 2020
2 parents 04f9e4e + 939b50e commit 2e1cab2
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 40 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.cache/
.coverage
.envrc
.git/
.github/
.idea/
.local/
.vagrant/
ember/node_modules/
htdocs/
41 changes: 3 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 3 additions & 2 deletions config/default.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import os
import os.path

here = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2e1cab2

Please sign in to comment.