Skip to content

Commit ca16659

Browse files
authored
[Doc] How to Include Private Packages (#309)
* [Doc] How to Include Private Packages * `yml` parser is unknown -> use `yaml` * deprecation: missing `configuration` key for `sphinx` * wrong dir name * fix from testing the docs
1 parent fe92763 commit ca16659

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

.readthedocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ conda:
1515

1616
sphinx:
1717
builder: html
18-
fail_on_warning: true
18+
fail_on_warning: true
19+
configuration: doc/_config.yml
20+

doc/faq/faq.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,79 @@ pip freeze > requirements.txt
7272
This will produce a new `requirements.txt` file with specific versions
7373
for each package, ensuring that upgrades to the dependencies don't break your app.
7474

75+
(private-packages)=
76+
## Including Private Packages
77+
78+
### UI & CLI
79+
To use a private packages, you'll have to do it via Docker:
80+
81+
1. Copy your framework's base Dockerfile to project root ([Streamlit](https://github.com/ploomber/doc/blob/main/examples/streamlit/docker-based/Dockerfile), [Dash](https://github.com/ploomber/doc/blob/main/examples/dash/docker-based/Dockerfile), other framework Dockerfile can be find in our [examples](https://github.com/ploomber/doc/tree/main/examples))
82+
83+
2. Clone your `package` to root directory (`git clone https://githib.com/org/package.git`), and **remove it from your `requirements.txt`**
84+
85+
3. Update Dockerfile:
86+
```Dockerfile
87+
FROM python:3.11-slim
88+
89+
WORKDIR /app
90+
91+
# ~~~~~~~~~~~~~ NEW ~~~~~~~~~~~~~~~~
92+
COPY package/ package/
93+
RUN pip install -e package/
94+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
95+
96+
COPY requirements.txt /app/
97+
RUN pip install -r requirements.txt --no-cache-dir
98+
99+
COPY . /app/
100+
101+
CMD ["streamlit", "run", "app.py"]
102+
```
103+
104+
4. Zip your project and deploy it (CLI users, simply do: `ploomber-cloud deploy`)
105+
106+
### GitHub Workflow
107+
For GitHub deployments, we need to add a package download step before the deployment step. Other steps remain same as UI/CLI method.
108+
109+
For this, you'll need to generate a personnal access token with access to the targeted repo.
110+
- [How to generate a Personnal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
111+
- [How to securely give CI access to private Git repos using a **Machine User**](https://github.com/orgs/gruntwork-io/discussions/784#discussioncomment-7644683)
112+
113+
```yaml
114+
jobs:
115+
deploy-to-ploomber-cloud:
116+
runs-on: ubuntu-latest
117+
defaults:
118+
run:
119+
working-directory: ./server
120+
steps:
121+
- uses: actions/checkout@v2
122+
- name: Set up Python
123+
uses: actions/setup-python@v2
124+
with:
125+
python-version: '3.11'
126+
- name: Install dependencies
127+
run: |
128+
python -m pip install --upgrade pip
129+
pip install ploomber-cloud
130+
# ~~~~~~~~~~~~~ NEW ~~~~~~~~~~~~~~~~
131+
- name: Download private package
132+
run: |
133+
# Clone private repository
134+
git clone https://${{ secrets.GH_TOKEN }}@github.com/org/package.git
135+
# /!\ Remove your package from requirements.txt
136+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137+
- name: Deploy
138+
env:
139+
PLOOMBER_CLOUD_KEY: ${{ secrets.PLOOMBER_CLOUD_KEY }}
140+
run: |
141+
ploomber-cloud deploy --watch-incremental
142+
```
143+
144+
```{note}
145+
Add `GH_TOKEN` secret in repository settings with permission to clone private package.
146+
```
147+
75148
## Displaying Chinese characters
76149

77150
If you're using matplotlib and want to display Chinese characters in your plots,

0 commit comments

Comments
 (0)