How to deploy Django Application on railway.app?

Published 12 Jan, 2023

Reading time: 1 Mins


Deploy Django application in railway.app easily with two steps

Deploying the application into railway.app is very easy process. As my previous article pointed out that you don’t need lot of changes in the code to make it work. Django deployment often result in many code changes but surprisingly deploying to railway.app is straightforward work.

Prepare the project

There is two changes you need to do in the codebase.

  1. Create a .python-version and requirements.txt file

    3.11
    
  2. Create the Procfile

    web: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn gaclient.wsgi
    

Prepare the railway.app

Head to railway.app and create the account if you have not and then create the empty project.

  1. Create the database
  2. Create an empty service.

Note that when you create the database it automatically updated the environment variable in the project. Where DATABASE_URL is easily accessible and populated already in the environment variable.

After that head to variable section and add the project environment variable. Then connect to your GitHub in settings page.

Voila 🎉 your application is live and you can access the page. Connect the domain in settings if you use it with your own domain.

Read More