Skip to content

Commit

Permalink
Update Heroku deployment for Celery and Redis integration
Browse files Browse the repository at this point in the history
  • Loading branch information
areebahmeddd committed Nov 15, 2024
1 parent 5b2b304 commit 17bfae0
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
web: gunicorn config.wsgi:application
release: python manage.py collectstatic --noinput && python manage.py migrate
worker: celery -A config.celery_app worker --loglevel=info
beat: celery -A config.celery_app beat --loglevel=info
74 changes: 47 additions & 27 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
{
"environments": {
"test": {
"scripts": {
"test": "python manage.py test"
},
"buildpacks": [{
"url": "https://github.com/cyberdelia/heroku-geo-buildpack.git"
},
{
"url": "heroku/python"
}
],
"env": {
"DJANGO_SETTINGS_MODULE": {
"value": "config.settings.test"
},
"LD_LIBRARY_PATH": {
"value": "/app/lib"
},
"BUILD_WITH_GEO_LIBRARIES": {
"value": "1"
}
}
}
}
}
{
"environments": {
"test": {
"scripts": {
"test": "python manage.py test"
},
"buildpacks": [
{
"url": "https://github.com/cyberdelia/heroku-geo-buildpack.git"
},
{
"url": "heroku/python"
}
],
"env": {
"DJANGO_SETTINGS_MODULE": {
"value": "config.settings.test"
},
"LD_LIBRARY_PATH": {
"value": "/app/lib"
},
"BUILD_WITH_GEO_LIBRARIES": {
"value": "1"
}
}
},
"production": {
"scripts": {
"postdeploy": "python manage.py migrate && python manage.py load_redis_index"
},
"env": {
"DJANGO_SETTINGS_MODULE": {
"value": "config.settings.production"
},
"DATABASE_URL": {
"value": "${DATABASE_URL}"
},
"REDIS_URL": {
"value": "${REDIS_URL}"
},
"CELERY_BROKER_URL": {
"value": "${CELERY_BROKER_URL}"
}
}
}
}
}
42 changes: 42 additions & 0 deletions docs/local-setup/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,45 @@ If you get an :code:`ImproperlyConfigured` error regarding the Spatialite librar
::

$ sudo apt install libsqlite3-mod-spatialite

Heroku Deployment
=================

To deploy the backend along with Celery on Heroku, follow these steps:

1. Ensure you have the Heroku CLI installed and are logged in.

2. Create a new Heroku app:

.. code-block:: bash
heroku create your-app-name
3. Add the necessary add-ons for PostgreSQL and Redis:

.. code-block:: bash
heroku addons:create heroku-postgresql:hobby-dev
heroku addons:create heroku-redis:hobby-dev
4. Set the environment variables:

.. code-block:: bash
heroku config:set DJANGO_SETTINGS_MODULE=config.settings.production
heroku config:set DATABASE_URL=your-database-url
heroku config:set REDIS_URL=your-redis-url
heroku config:set CELERY_BROKER_URL=your-redis-url
5. Deploy the app:

.. code-block:: bash
git push heroku main
6. Run the migrations and load the Redis index:

.. code-block:: bash
heroku run python manage.py migrate
heroku run python manage.py load_redis_index

0 comments on commit 17bfae0

Please sign in to comment.