Hi there, I try to move a project from Render which is very slow to AWS. It's a Python project using Flask. I put the same commands or config that I have on render but it fails. Here are the screenshots of my config and the related logs. If you have any idea on how to proceed? Thanks in advance.
#Moving from Render to AWS
1 messages · Page 1 of 1 (latest)
The error is saying that gunicorn doesn't exist as a command
is this a global package locally? It would need to be installed in the container, and added to the environments $PATH.....if im understanding the error correctly.
I am not as familiar with python and the pip ecosystem as I am primarily a typescript/php dev, but see step 5 in this post....you may need the bind flag.....hopefully this helps.
https://berkoc.medium.com/how-to-deploy-your-flask-app-to-aws-ec2-instance-with-nginx-gunicorn-b734df606a14
Medium
This post will walk you through that how you can deploy the flask application on AWS EC2 instance.
thank you so much really appreciate, will have a look at it, because gunicorn should be installed correctly as it works with render, but we'll see your article
In my experience if it isn't installed global, I would need to use the package manager to run the command because the binary will be installed to the local source code, but if it needs to be global on the container then I can use the command directly, like you are trying. Let me know what you find, if you don't mind. I'm curious to know.
Example with yarn
local in project yarn [command]
global to machine [command], because the binary is on the machine and added to the $PATH.
it's also possible that Render has abstracted something I am unaware of. And im not sure you are using EC2 like that post.
yes sure I will let you know. The thing is that I don't use container, I've choosen to deploy from a repo and not from container.
what AWS resource is hosting the site?
what do you mean by that sorry dont't get it
so you deploy the code from a repository, but it needs to be served somewhere after being built and deployed. That can be S3, ECS, EC2 or other combinations with Lambda etc.
since im assumming gunicorn is http requests, there should be a server to handle the requests in AWS. Which is where your code should be deploying to after build.
oh okay it's app runner. It's the first time I use AWS
ah...I think you said that....my bad. Let me look at app runners docs
thanks so much
do you have a yaml for the config? which method are you using?
requirements.txt file
is this a private repo?
the build works in the logs only the start command fails
no as it is already deploy to render
or maybe because it's already running somewhere else?
can you share the repo link with me?
this shouldn't be the case. It's separate infrastructure
Render
bash: gunicorn app:app: command not found Re-type your Start Command character by character. Anyone having this error needs to clear their Start Command and re-type it all character by character. I recommend Ctrl+a (Command+a if you’re on macOS), backspace, re-type. The important part of this is that it says gunicorn app:app is not found. This...
this could be something.....the actual characters used for the command. I need to hop away for a bit. I will try to look at the repo and see if I can find something this evening.
thank you so much I work on it to see if can find something
Ignore this. I don't think that's your issue. I misread.
I gonna try because I pasted the command nothing to loose
copy/paste is the devil
you see the placeholder is gunicorn
keeps failing
same error
the start command doesn't work
On push
Learn about the Python platform that AWS App Runner provides for building and running Python-based web applications.
you have all this done? I don't see it in the repo.
requirements.txt is the packages, but I don't see anything actually configuring app runner
This is when choosing a container that you have to set up the yaml file. I choose the option to deploy with the repo. I’ve filled up the fields. I think it might be the path of my Python version or the gunicorn but I don’t think so as I’ve used a Python environment. Will check later have to pick up the kids. Thanks again for your help
of course...if I find anything else I will let you know
All the examples that I’ve found or articles are only with docker not with repo 😡
well....theres a container there whether you set it up or not, just know that.
what you are doing now is what vercel, netlify and all the others have abstracted.
Yes I know I thought it was going to be easier 🤣🤣
My guess is that the python env in the container isn't correct.
run:
runtime-version: 3.11
pre-run:
- pip3 install pipenv
- pipenv install
- python3 copy-global-files.py
command: pipenv run gunicorn django_apprunner.wsgi --log-file -
try specifying pipenv to run gunicorn
it's tricky to swap runtime providers because you're never quite sure which abstractions they include, I suspect if you used another container service like Fargate or a managed EC2 service like Elastic Beanstalk, you'd get a different set of requirements.
further, in the app runner environment, it may expect more flags on the gunicorn command with a settings file
Does it potentially need bind for ip and port?
port binding is further down the process, currently, the container is trying to bootstrap the process with an invalid calling path. The problem is configuring the container service to have the right python environment. Tools like pipenv attempt to standardize it, pip and python don't quite act like npm and node.
Ahh, so pipenv knows where it all is?
yea, pipenv makes a virtual environment and tries to intercept all the dependencies into a local config.
now you can see how node_modules ends up being the black hole that it is
in python, there's like "system python" which is built into the OS, and then theres your python
keeping them separate is a pain
everytime I do python, it takes me forver to get the virtual env correct
yeah, ts/js builds are bad enough, that seems like a second env in a container and could get twisted up easily.
@round widget , if I were to debug this, I'd write a bash file to log out path variables and create verbose install logs to force app runner to give me more info.
app runner, is a service that takes in simple commands to instantiate your whole app inside a container. at this point you are fighting against the virtual machine attempting to run your app. somewhere in AWS is a cpu with the most basic permissions doing its best.
This situation illustrates a common misconception that workloads are portable. Even if you fully containerize an app, whenever you switch platforms, there's always some level of incompatibility.
Curious, why is Render slow? Are you reaching the service limits on Render?
So much help thank you so much @cerulean crypt and @olive relic. I will try things tonight. What I don't understand @cerulean crypt is that I don't use container it's only with my repo, I shouldn't have to set up any yaml file. I also use venv to set up my environment I'm thinking right now that I've used Python 3.12 for the project and on AWS they have until 3.11. Does that matter? That's probably why the path is not found? On render I took the free tier and it takes so long to show the page. You can test it if you want https://community-blog-dia1.onrender.com/register that's why I wanted to change.
I don't know how to do that 🤣
now's a good time to learn 😛