How to Deploy a Django app to AWS Lightsail
HTML-код
- Опубликовано: 11 сен 2024
- This is an edited version of our live stream: How to Deploy a Django app to AWS Lightsail.
AWS has an exciting product called Lightsail. It offers a lightweight, simplified deployment with transparent pricing. Win win.
Familiarise yourself with AWS Lightsail: aws.amazon.com...
Here's the finished code with code diffs for each step: github.com/Lon...
And here's the AWS Lightsail Live Stream Preparation tutorial: • AWS Lightsail Live Str...
Thank you for this excellent video. You answered all of the questions that would have taken me weeks or even months to research. Thank you again👍
Glad it was helpful!
This was an amazing video. Thank you so much, it was extremely useful and I learned a lot! You have a new fan here. Liked and subscribed, of course!
Thanks so much!
Thanks, was waiting for this video. I attended the live, but still wanted to have this reference in case I forgot anything.
So I'm going through this with my own project and I'm getting the following error when trying to do my first "migrate"
django.db.utils.OperationalError: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Is the server running locally and accepting connections on that socket?
At the end, I get this error when creating superuser "[15/May/2023:19:49:40] Superuser created successfully.
[15/May/2023:19:50:00] [deployment:14] Started 1 new node
[15/May/2023:19:50:23] CommandError: Error: That username is already taken.
[15/May/2023:19:51:29] [deployment:14] Started 1 new node
[15/May/2023:19:51:54] CommandError: Error: That username is already taken" ...
"Forbidden (403)
CSRF verification failed. Request aborted.
More information is available with DEBUG=True."
Great effort! Thank you for sharing your knowledge.
Thank you!
@@LondonAppDeveloper এএঊঊঊঊঊঊঊউউউআঊঊঊউউঊ ঊঊঊউউউ
si was was running a django app using rds, ec2, load balancers etc.. but it was just too expensive... How is deploying to lightsail cost? wat monthly cost are we looking at?
You can get all the pricing here: aws.amazon.com/lightsail/pricing/
Too be honest, the price might be similar to using EC2 / Load Balancer / RDS directly. The benefit of lightsail is that the pricing is more predictable.
If you want something really cheap then best bet is to run everything on a single VPS (database, app, etc...). For this, my personal preference is katapult.io. You could also check out fly.io/docs/about/pricing/
I am facing an issue, it states:
exec /scripts/run.sh: no such file or directory
Please help me understand the issue and the way to resolve it
Is the run.sh file spelled correctly and in the right location?
Thanks very much for this. Sorry I missed it live.
No worries. We're doing another on March 15th. if you can come.
You are amazing!!
Thank you! So are you.
Thanks for the video!
What is the average cost of this kind of setup?
I think roughly $30 a month.
Why do I keep getting this error;
[26/Jul/2024:21:50:59] django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '172.26.31.219'. You may need to add '172.26.31.219' to ALLOWED_HOSTS.
To clarify the request are coming in every 5 seconds, so I'm wondering if some sort of internal health check?
In case anyone ends up wondering - solved this with; ALLOWED_HOSTS = []
ALLOWED_HOSTS.extend(
filter(None, os.environ.get('ALLOWED_HOSTS', '').split(','))
)
ALLOWED_HOSTS.append(gethostbyname(gethostname())). Do please let me know if this isn't best practice
As some have pointed out, to resolve this you’ll need to add the IP address of the running host to the ALLOWED_HOSTS in settings.py.
There's an example in our API deployment course: github.com/LondonAppDeveloper/devops-recipe-app-api/blob/main/app/app/settings.py#L38
Essentially:
```
from socket import gethostname, gethostbyname
…
ALLOWED_HOSTS = []
ALLOWED_HOSTS.append(gethostbyname(gethostname()))
```
@@LondonAppDeveloper that’s great thank you. First website now deployed and working well - thanks for the video!