Reputation: 2631
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).
Upvotes: 12
Views: 2043
Reputation: 1074
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.
Upvotes: 6