简体   繁体   中英

How to deploy a subdirectory of git repo to elastic beanstalk

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).

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:

  1. 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)

  1. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM