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?
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!
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.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
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:
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.
Add the Personal Access Token to Your App Platform Environment:
Settings
tab.Environment Variables
section, add a new environment variable. Name it something likeGITHUB_PAT
and paste your Personal Access Token as its value.Modify your
requirements.txt
:Use the environment variable in your
requirements.txt
file to install the private repo. Here’s a generalized format:When App Platform builds your app, it will replace
$GITHUB_PAT
with the actual token, allowingpip
to authenticate and download the private package.Redeploy Your App:
With these changes, redeploy your app on the App Platform.
Let me know how it goes!
Best,
Bobby