I'm fairly new to elastic beanstalk. It was not obvious to me that committing to git was required for deploying, but now I've found in the docs that it uses git archive
behind the scenes to make a zip that gets deployed.
How can I deploy a subdirectory of a large project only; without uploading the entire contents of the repo?
Say I have a structure like:
git-repo/
mobile/
ios/...
android/...
assets/...
django-app/
.ebextensions
manage.py
site/...
...
I want to deploy just django-app
and below.
Ideally I'd avoid using subtrees, and avoid other scripts (but scripts would be okay if eb deploy
has a way to automate them).
Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list. If you have many environments, use the search bar to filter the environment list. Choose Upload and deploy.
On the environment overview page, choose Upload and deploy. Choose Choose file, and then upload the sample application source bundle that you downloaded. The console automatically fills in the Version label with a new unique label. If you type in your own version label, ensure that it's unique.
Assuming you have installed and set up the EB CLI you can create a script to zip your django-app/ folder and then deploy the resulting artefact:
Create a folder in your project root called .ebextensions and inside this folder create a file called config.yml with the following basic contents:
deploy: artifact: "deploy.zip"
(note the spacing is very important in a yml file, "deploy" should be in the first column, "artifact" in a secod (tab spaced) column)
Create a deploy.sh script in your project root with the following:
git archive --format=zip HEAD:django-app/ > deploy.zip; eb deploy;
Note: this works very well on Mac and Linux, I've had issues in the past with Windows because of spaces in the user folder structure on Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With