Alright guys, at the end of this article I hope you should be able to deploy your first Django project on Railway app.
Railway app is a cloud platform that gives you simple configured free deploys, removing common developer hurdles with zero CLI, just to add as a bragging rights it has a faster build time than Heroku, interestingly I discovered it while I was having issues deploying my project to Heroku check here to see how I did that.
All you need to get started is your GitHub repo. Railway has some starter applications which can be deployed on the go, and it also comes with a PostgreSQL as the default database manager.
In this article an explanation to some of the terminologies used here are not given, it is assumed that the reader must be familiar with them if not check out this article where I explain these terminologies in details.
With that much said let us dive in, using these steps i'll show you how to deploy your Django projects on railway.
Ensure you already have a Railway account if don't you can sign-up here, A GitHub account and the project you want to deploy is been cloned once you’re done these 3 basic things follow these steps.
pip install guinicorn
pip freeze > requirements
Procfile in your root folder and save the following lines of codes in it
web: gunicorn 'name-of-application.wsgi'
Note: A Procfile has no file extension
Railway needs to know the version of python you used for your project, to know the version used type
python --version in your terminal copy, paste and save the version inside your
Next, we need to make some adjustments to our
Look for the line that has
ALLOWED_HOST = [ ]
and change it to
ALLOWED_HOST = ['*']
Still on your
settings.py file add the following lines of codes in your static section, so your static files can be properly rendered
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATIC_ROOT =os.path.join(BASE_DIR, 'staticfiles')
Lastly, we collect our static files into one folder using the following command
python manage.py collectstatic
Next, we push our project to our Github account where we’ll be deploying our project from. Use the following git syntax to add, commit and push your code.
git add .
git commit -m ‘customized commit message’
Now, we move to our railway app account that was created
select a repo and Railway pack helps you build and automatically deploy your project using nixpacks you can see the build status as it is been built, once that has been done,
click on your project go to the
under domain click generate domain
a customized link to your deployed app is been created you can visit it by clicking on it.
Your project has been deployed.