diff --git a/Dockerfile b/Dockerfile index 0ccc619..66d9b7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,25 +2,21 @@ FROM python:3.6.3 ENV PYTHONUNBUFFERED 1 -# Create root directory for our project in the container -RUN mkdir /src - -# Create application subdirectories +# Create application root directory WORKDIR /src + RUN mkdir media static logs VOLUME [ "/src/logs" ] -# Copy the current directory contents into the container at sensorsafrica -ADD . /src/ - -# Upgrade pip and setuptools -RUN pip install -q -U pip setuptools +# Upgrade pip and setuptools with trusted hosts +RUN python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip setuptools -# Install feinstaub from opendata-stuttgart -RUN pip install -q git+https://github.com/opendata-stuttgart/feinstaub-api +# Copy the current directory contents into the container at sensorsafrica +COPY . /src/ -# Install sensors.AFRICA-api and its dependencies -RUN pip install -q -U . +# Upgrade pip and setuptools, install dependencies +RUN pip install -q git+https://github.com/opendata-stuttgart/feinstaub-api && \ + pip install -q -U . # Expose port server EXPOSE 8000 @@ -31,3 +27,4 @@ COPY ./contrib/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] CMD [ "/start.sh" ] + diff --git a/README.md b/README.md index 1f70360..deea24f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ API to save and access data from deployed sensors in cities all around Africa. ## Documentation -The API is documented [here.](https://github.com/CodeForAfricaLabs/sensors.AFRICA-api/wiki/API-Documentation) +The API is documented [here.](https://github.com/CodeForAfricaLabs/sensors.AFRICA-api/wiki/API-Documentation) ## Development @@ -29,6 +29,11 @@ GRANT ALL PRIVILEGES ON DATABASE sensorsafrica TO sensorsafrica; - Migrate the database; `python manage.py migrate` - Run the server; `python manage.py runserver` +- Create super user for admin login; `python manage.py createsuperuser` + + username: `` + email: blank + password: `` ### Docker diff --git a/docker-compose.yml b/docker-compose.yml index 49c12ef..8a1c12a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,15 +2,20 @@ version: '3.3' services: rabbitmq: - image: rabbitmq:3.5.1 + image: rabbitmq:3.12.7-management ports: - - 4369:4369 - - 5672:5672 - - 25672:25672 - - 15672:15672 + - "5672:5672" + # GUI port + - "15672:15672" environment: - - RABBITMQ_USERNAME=sensorsafrica - - RABBITMQ_PASSWORD=sensorsafrica + - RABBITMQ_DEFAULT_USER=sensorsafrica + - RABBITMQ_DEFAULT_PASS=sensorsafrica + healthcheck: + test: [ "CMD-SHELL", "rabbitmq-diagnostics -q ping" ] + interval: 10s + timeout: 5s + retries: 2 + postgres: image: postgres:13.7 ports: @@ -25,12 +30,11 @@ services: build: context: . environment: - SENSORSAFRICA_DATABASE_URL: postgres://sensorsafrica:sensorsafrica@postgres:5432/sensorsafrica - SENSORSAFRICA_READ_DATABASE_URLS: postgres://sensorsafrica:sensorsafrica@postgres:5432/sensorsafrica - SENSORSAFRICA_RABBITMQ_URL: amqp://sensorsafrica:sensorsafrica@rabbitmq// - SENSORSAFRICA_FLOWER_ADMIN_USERNAME: admin - SENSORSAFRICA_FLOWER_ADMIN_PASSWORD: password - DOKKU_APP_NAME: sensorsafrica + SENSORSAFRICA_DATABASE_URL: ${SENSORSAFRICA_DATABASE_URL:-postgres://sensorsafrica:sensorsafrica@postgres:5432/sensorsafrica} + SENSORSAFRICA_RABBITMQ_URL: ${SENSORSAFRICA_RABBITMQ_URL:-amqp://sensorsafrica:sensorsafrica@rabbitmq/} + SENSORSAFRICA_FLOWER_ADMIN_USERNAME: ${SENSORSAFRICA_FLOWER_ADMIN_USERNAME:-admin} + SENSORSAFRICA_FLOWER_ADMIN_PASSWORD: ${SENSORSAFRICA_FLOWER_ADMIN_PASSWORD:-password} + DOKKU_APP_NAME: ${DOKKU_APP_NAME:-sensorsafrica} depends_on: - postgres - rabbitmq diff --git a/requirements.txt b/requirements.txt index 92145ee..086b243 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,7 +18,7 @@ ckanapi==4.1 celery-slack==0.3.0 -urllib3<1.25,>=1.21.1 #requests 2.21.0 +urllib3<2 django-cors-headers==3.0.2 diff --git a/sensorsafrica/settings.py b/sensorsafrica/settings.py index fcbbf17..2377373 100644 --- a/sensorsafrica/settings.py +++ b/sensorsafrica/settings.py @@ -113,13 +113,6 @@ DATABASES = {"default": dj_database_url.parse(DATABASE_URL), } -READ_DATABASE_URLS = os.getenv("SENSORSAFRICA_READ_DATABASE_URLS", DATABASE_URL).split(",") - -for index, read_database_url in enumerate(READ_DATABASE_URLS,start=1): - DATABASES[f"read_replica_{index}"] = dj_database_url.parse(read_database_url) - -DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter", ] - # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators