Python Web App CI/CD Using Github Actions and AWS EC2 | Deploy Langchain Flask Django App On Server
ฝัง
- เผยแพร่เมื่อ 15 ก.ย. 2024
- Deploy LangChain and Flask Application Using Github Actions and AWS EC2 (Gunicorn & Nginx)
Steps:-
1. Create EC2 instance.
2. Add GitHub env variables.
3. Add GitHub actions, deployment script, and requirements.txt
Github action file:- github.com/Tri...
Bash Script:- github.com/Tri...
#python #flask #langchain #django #deployment #awsec2
thanks for the guide its working but i want to ask do we really have to delete the whole project and recopy it everytime we push what if project is big and change is very small do we still have to do the same process or there is any other efficient way
Hi
In GitHub action, "rsync" command can be used instead of "src" (line 37 of deploy.yaml):-
rsync -avz --delete ./ $EC2_USERNAME@$EC2_HOST:/var/www/langchain-app
After that "sudo mv * /var/www/langchain-app" command from bash script can be removed:- github.com/TrickSumo/langchain-course-python/blob/16-CICD-PYTHON-WEBAPP/deploy.sh#L10
Does this require you to push the generated .env file to your github repo?
No, env variables are stored as GitHub repo environment secret. th-cam.com/video/W8tONeBuTn0/w-d-xo.html
These secrets are used to create .env file dynamically.
So your keys are never exposed publically.
Home Work hint =>
1. To get instance IP address in the bash script, use:-
curl 169.254.169.254/latest/meta-data/public-ipv4
(make sure to do:- EC2 instance >> Instance settings >> Modify instance metadata options >> IMDSv2 >> Optional)
2. Use "sed" Linux command to search and replace IP address in the "index.html"