anitab-forms-backend
anitab-forms-backend copied to clipboard
[Feat]: Add heroku configuration for deployment
Description
Add heroku configuration for deployment Fixes #80
Instructions for deployment :
- Login to Heroku
heroku login
- After you have executed the command ‘heroku login’, in the web browser, you are now redirected to the page as shown in the image below. Here, you are required to click on the ‘Log In’ button.
- Now, you are required to create an app in Heroku. Hence, for the stated purpose you are required to execute the following command.
heroku create open-source-programs-backend
- After the successful execution of the command you can now view your application in Heroku devcenter.
- For deploying your application you are required to execute the following command.
git push heroku develop
- To commit initial migration on the Heroku application you are required to execute the following query.
heroku run python manage.py migrate
- Finally, you can execute the following command to view the hosted website.
heroku open
Type of Change:
- Code
- Outreach
Code/Quality Assurance Only
- New feature (non-breaking change which adds functionality pre-approved by mentors)
How Has This Been Tested?
Not Applicable
Checklist:
- [x] My PR follows the style guidelines of this project
- [x] I have performed a self-review of my own code or materials
Code/Quality Assurance Only
- [x] My changes generate no new warnings
@codesankalp @isabelcosta Can you please review this PR. Thanks 🙂
@Rahulm2310 Will this be able to deploy from the Heroku pipeline through github?
QA checks are also failing.
@Rahulm2310 Follow the README guidelines for QA-Checks as both workflows are failing.
@codesankalp Can you please explain why both workflows are still failing?
@Rahulm2310 Try to follow the commands mentioned in README - https://github.com/anitab-org/open-source-programs-backend#qa-checks You can also check the suggestion of the workflow. When QA-Checks will pass I will review this PR.
For testing, you can use gunicorn main.wsgi
.
I tried it on the local system and it is returning 500 server errors for URL which is working.
I think that is may be because you don't have DJANGO_DEBUG
in your .env file.
Also, I am getting this when running gunicorn main.wsgi
.
@Rahulm2310 I have DJANGO_DEBUG in my .env
file. DJANGO_DEBUG=False will be used in production which only means any error will not be shown on the deployed backend.
And I am not sure why gunicorn main.wsgi
returns an error in windows because I tried it on Ubuntu. You can research about this error.
But what I wanted is that after running this command it must not show any errors (Server error 500).
@codesankalp I came to know that gunicorn is for unix environment and is incompatible with windows. There is an open issue on the gunicorn's github repo for this.
Then @Rahulm2310 there is only one option try deploying on Heroku for testing your code.
@codesankalp is this the correct way DEBUG = os.environ.get("DJANGO_DEBUG", "") != "False"
?
Also, this works if I remove DJANGO_DEBUG from .env file.
@Rahulm2310 The line that you have added is correct i.e. it will make DEBUG=False when DJANGO_DEBUG=False
will be present in .env
file else it will make DEBUG=True in any other remaining condition.
@codesankalp I tried deploying to heroku. But getting this error when running heroku run python manage.py migrate
.
.
Although, I have download
file in the project's root still shows this.
Try to rebase it with the current develop branch then there will be no errors regarding Zulip Key.
The download file is in your local directory but as it is also present in .gitignore
because of this it is not present in heroku.
@codesankalp I rebased with current develop, pushed the download file to heroku and then heroku run python manage.py migrate
ran successfully. Here's the deployed link https://open-source-programs-backend.herokuapp.com/api. Could you please check and confirm if it looks alright so that I can push the changes here.
I tried making a user and it returns a server error.
Maybe you need to set up all environment variables (including sendgrid email) in the
.env
file.
Maybe you need to set up all environment variables (including sendgrid email) in the .env file.
I tried adding SENDGRID_API_KEY
to heroku config vars(environment variables), still showing the same error. Also, when I tried it locally it gives me this error
Although, my
from
address is verified sender identity on sendgrid, still getting this error.
Maybe you need to set up all environment variables (including sendgrid email) in the .env file.
I tried adding
SENDGRID_API_KEY
to heroku config vars(environment variables), still showing the same error. Also, when I tried it locally it gives me this errorAlthough, my
from
address is verified sender identity on sendgrid, still getting this error.
Is it working on local and not working on heroku?
@codesankalp getting server error
when registering a user on heroku.
This is the error when registering a user on local.
@Rahulm2310 See this for reference: https://sendgrid.com/docs/ui/sending-email/sender-verification/
@codesankalp I have my sender email verified on sendgrid.
Can I add you as a collaborator to the deployed project on heroku.
No, It is not needed @Rahulm2310. If it's a problem related to SendGrid then I will suggest using another email service or consoleBackend. Let me know if it was able to solve the problem. Also, Can you access the admin site and was able to create a user from there?
If it's a problem related to SendGrid then I will suggest using another email service or consoleBackend.
@codesankalp I tried consoleBackend, and I am getting the verification mail in the console.
Seems that this is a problem related to sendgrid.
Also, Can you access the admin site and was able to create a user from there?
yeah I created a super user for heroku app and then created a new user from the admin site.
@Rahulm2310 In that case I can approve this PR. I will review it again soon.
@Rahulm2310 Can you please resolve the merge conflict and do the suggested changes?
@codesankalp was a bit more involved in OSH. Will apply the suggested changes asap. 🙂
Hi, @Rahulm2310 can you do the changes in this, as the deployment of the backend, is one of the high priority things for us currently.
@Rahulm2310 It is a priority now because the deployed backend is required. Can you please update the PR?
@codesankalp can you help me identify why CI builds are failing
@codesankalp can you help me identify why CI builds are failing
Not sure, It is something related to postgres. I think while deleting the database it can't delete it. I will research about it more.