Skip to content

Commit

Permalink
chore: remove Celery and Redis dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 12, 2021
1 parent f84444c commit ba0d984
Show file tree
Hide file tree
Showing 48 changed files with 227 additions and 936 deletions.
10 changes: 0 additions & 10 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,3 @@
# ------------------------------------------------------------------------------
USE_DOCKER=yes
IPYTHONDIR=/app/.ipython
# Redis
# ------------------------------------------------------------------------------
REDIS_URL=redis://redis:6379/0

# Celery
# ------------------------------------------------------------------------------

# Flower
CELERY_FLOWER_USER=debug
CELERY_FLOWER_PASSWORD=debug
24 changes: 1 addition & 23 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres
CELERY_BROKER_URL: ${{ secrets.CELERY_BROKER_URL }}
GOOGLE_APPLICATION_CREDENTIALS: "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}"
DJANGO_GCP_STORAGE_BUCKET_NAME: ${{ secrets.DJANGO_GCP_STORAGE_BUCKET_NAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -22,17 +21,6 @@ jobs:
linter:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
Expand Down Expand Up @@ -76,17 +64,6 @@ jobs:

# Service containers to run with `container-job`
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres
env:
Expand Down Expand Up @@ -118,6 +95,7 @@ jobs:
- name: Set up Django
run: |
python manage.py migrate
python manage.py createcachetable
python manage.py collectstatic --noinput
- name: Run tests and collect coverage
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ target/
# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# Environments
.venv
venv/
Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MASTER]
load-plugins=pylint_django, pylint_celery
load-plugins=pylint_django
django-settings-module=pepfar_mle.config.settings.test

[FORMAT]
Expand Down
1 change: 0 additions & 1 deletion Dockerfile

This file was deleted.

85 changes: 85 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
ARG PYTHON_VERSION=3.9-slim-buster

FROM node:10-stretch-slim as client-builder

ARG APP_HOME=/app
WORKDIR ${APP_HOME}

COPY ./package.json ${APP_HOME}
RUN npm install && npm cache clean --force
COPY . ${APP_HOME}
RUN npm run build

# define an alias for the specfic python version used in this file.
FROM python:${PYTHON_VERSION} as python

# Python build stage
FROM python as python-build-stage

ARG BUILD_ENVIRONMENT=production

# Install apt packages
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
# psycopg2 dependencies
libpq-dev

# Requirements are installed here to ensure they will be cached.
COPY ./requirements .

# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r ${BUILD_ENVIRONMENT}.txt


# Python 'run' stage
FROM python as python-run-stage

ARG BUILD_ENVIRONMENT=production
ARG APP_HOME=/app

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV BUILD_ENV ${BUILD_ENVIRONMENT}

WORKDIR ${APP_HOME}

RUN addgroup --system django \
&& adduser --system --ingroup django django


# Install required system dependencies
RUN apt-get update && apt-get install --no-install-recommends -y \
# psycopg2 dependencies
libpq-dev \
# Translations dependencies
gettext \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*

# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
# copy python dependency wheels from python-build-stage
COPY --from=python-build-stage /usr/src/app/wheels /wheels/

# use wheels to install python dependencies
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/


COPY --chown=django:django ./entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
RUN chmod +x /entrypoint

COPY --chown=django:django ./start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start

# copy application code to WORKDIR
COPY --from=client-builder --chown=django:django ${APP_HOME} ${APP_HOME}

# make django owner of the WORKDIR directory as well.
RUN chown django:django ${APP_HOME}
USER django
ENTRYPOINT ["/entrypoint"]
2 changes: 0 additions & 2 deletions Procfile

This file was deleted.

15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,6 @@ See:
* <http://cookiecutter-django.readthedocs.io/en/latest/live-reloading-and-sass-compilation.html>
* <https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss>

Celery
------

This app uses Celery for background tasks.

To run a celery worker:

```bash
> cd pepfar_mle
> celery -A config.celery_app worker -l info
```

Please note: For Celery's import magic to work, it is important *where* the celery commands are run.
If you are in the same folder with *manage.py*, you should be right.

Email Server
------------

Expand Down
30 changes: 29 additions & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@ steps:
["push", "europe-west1-docker.pkg.dev/$PROJECT_ID/sghi/mle:$COMMIT_SHA"]

# Deploy an image from Container Registry to Cloud Run
# TODO POSTGRES_HOST
# TODO POSTGRES_PORT
# TODO POSTGRES_DB
# TODO POSTGRES_USER
# TODO POSTGRES_PASSWORD
# TODO DATABASE_URL
# TODO DJANGO_SECRET_KEY
# TODO DJANGO_ADMIN_URL
# TODO DJANGO_ALLOWED_HOSTS
# TODO DJANGO_SECURE_BROWSER_XSS_FILTER
# TODO DJANGO_SECURE_SSL_REDIRECT
# TODO DJANGO_SECURE_CONTENT_TYPE_NOSNIFF
# TODO DJANGO_SECURE_FRAME_DENY
# TODO DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS
# TODO DJANGO_SESSION_COOKIE_HTTPONLY
# TODO DJANGO_SESSION_COOKIE_SECURE
# TODO DJANGO_SERVER_EMAIL
# TODO DJANGO_DEFAULT_FROM_EMAIL
# TODO DJANGO_EMAIL_SUBJECT_PREFIX
# TODO DJANGO_SENTRY_LOG_LEVEL
# TODO SENTRY_TRACES_SAMPLE_RATE
# TODO MAILGUN_API_KEY
# TODO MAILGUN_DOMAIN
# TODO MAILGUN_API_URL
# TODO DJANGO_GCP_STORAGE_BUCKET_NAME
# TODO DJANGO_ACCOUNT_ALLOW_REGISTRATION
# TODO SENTRY_DSN=https://a05704bb311943c1b1d737b60b64c09c@errors.bewell.co.ke/6

- name: 'gcr.io/cloud-builders/gcloud'
args: [
'run',
Expand All @@ -24,7 +52,7 @@ steps:
'--region', 'europe-west1',
'--platform', 'managed',
'--allow-unauthenticated',
'--update-env-vars', 'SENTRY_ENVIRONMENT=prod,COMPRESS_ENABLED=true,DJANGO_DEBUG=false'
'--update-env-vars', 'SENTRY_ENVIRONMENT=prod,COMPRESS_ENABLED=true,DJANGO_DEBUG=false,USE_DOCKER=yes,DJANGO_READ_DOT_ENV_FILE=False,DJANGO_SETTINGS_MODULE=config.settings.production,DJANGO_SECURE_SSL_REDIRECT=False,WEB_CONCURRENCY=4'
]

images:
Expand Down
81 changes: 0 additions & 81 deletions compose/local/django/Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions compose/local/django/celery/beat/start

This file was deleted.

10 changes: 0 additions & 10 deletions compose/local/django/celery/flower/start

This file was deleted.

7 changes: 0 additions & 7 deletions compose/local/django/celery/worker/start

This file was deleted.

9 changes: 0 additions & 9 deletions compose/local/django/start

This file was deleted.

31 changes: 0 additions & 31 deletions compose/local/docs/Dockerfile

This file was deleted.

Loading

0 comments on commit ba0d984

Please sign in to comment.