Setting up private Github access with AWS Elastic Beanstalk and Ruby container

前端 未结 5 1838
北恋
北恋 2020-12-13 04:47

Going by a recent tutorial on setting up AWS Elastic Beanstalk for Ruby deployment using Git, I just set up a Elastic Beanstalk environment from my CI server. However, the a

5条回答
  •  醉话见心
    2020-12-13 05:01

    Remove the private github repos from your requirements.txt file and create a script to install them using environmental variables for usernames and passwords.

    file: project-root/install-extra-requirements.sh

    #!/bin/sh
    
    source /opt/python/run/venv/bin/activate
    python ".extra-requirements.py"
    

    file: project-root/.extra-requirements.py

    import os
    
    def main():
        github_username = os.environ['GITHUB_USERNAME']
        github_password = os.environ['GITHUB_PASSWORD']
        repository = "git+https://%s:%s@github.com/yourgithubrepo" % (github_username, github_password)
        os.system("pip install %s" % repository)
    
    if __name__ == '__main__':
        main()
    

    file: project-root/.ebextensions/002_container.config

    container_commands:
      01_install_extra_requirements:
        command: './install-extra-requirements.sh'
    

    Now you can just set GITHUB_USERNAME and GITHUB_PASSWORD as environmental variables in your elastic beanstalk environment.

提交回复
热议问题