Question

Installing Private Python Repo to App Platform

I have a django project with the requirements.txt given so that app platform can install related dependencies. However, I also have 2 private repos that I built that need to be added. I can install them from the console by pip install git+https://github.com… but I would like to automate it so that I wouldn’t have to do it after each deployment.

How can I add this private repo installation into the app platform dependency install phase?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

If you want to install packages from a private repository during the build phase in DigitalOcean’s App Platform, you’ll need to provide a method for the build environment to authenticate against the private repository.

One way of doing this would be to:

  1. Generate a Personal Access Token:

    For GitHub, you can generate a Personal Access Token (PAT) by going to your account’s Developer Settings → Personal access tokens → Generate new token. Ensure that the token has the necessary scopes for reading your private repositories.

  2. Add the Personal Access Token to Your App Platform Environment:

    • Navigate to your app in the DigitalOcean App Platform dashboard.
    • Go to the Settings tab.
    • Under the Environment Variables section, add a new environment variable. Name it something like GITHUB_PAT and paste your Personal Access Token as its value.
  3. Modify your requirements.txt:

    Use the environment variable in your requirements.txt file to install the private repo. Here’s a generalized format:

    git+https://${GITHUB_PAT}@github.com/username/repo_name.git#egg=package_name
    

    When App Platform builds your app, it will replace $GITHUB_PAT with the actual token, allowing pip to authenticate and download the private package.

  4. Redeploy Your App:

    With these changes, redeploy your app on the App Platform.

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel