Skip to content

Commit 929c3d0

Browse files
authored
Merge pull request #77 from chmeliik/pip-custom-index
Document support for custom pip index servers
2 parents 34ca097 + fab3354 commit 929c3d0

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

docs/modules/ROOT/pages/how-tos/configuring/prefetching-dependencies.adoc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,60 @@ spec:
204204
* From the {ProductName} *Applications* view, go to *Activity > Latest commits*.
205205
//include::../partials/con_hermetic_verification.adoc[]
206206

207+
=== Prefetching `pip` dependencies from custom index servers
208+
209+
Cachi2 supports the link:https://pip.pypa.io/en/stable/cli/pip_install/#install-index-url[--index-url] option.
210+
You can add this option to your `requirements.txt` file(s), instructing Cachi2 to download packages from the specified
211+
index server. For example:
212+
213+
[source,text]
214+
----
215+
--index-url=https://example.pypi.org/simple/
216+
requests==2.32.2 \
217+
--hash=sha256:dd951ff5ecf3e3b3aa26b40703ba77495dab41da839ae72ef3c8e5d8e2433289 \
218+
--hash=sha256:fc06670dd0ed212426dfeb94fc1b983d917c4f9847c863f313c9dfaaffb7c23c
219+
220+
# ...other packages
221+
----
222+
223+
WARNING: Do not include credentials in the index url. If needed, provide authentication through a `.netrc` file (as described below).
224+
225+
To provide `.netrc` authentication for the index server:
226+
227+
. Create a key/value secret (see xref:/how-tos/configuring/creating-secrets.adoc[creating secrets for your builds]).
228+
Set `.netrc` as the key. Upload the content of your `.netrc` file as the value. For more details on netrc files,
229+
review the link:https://pip.pypa.io/en/stable/topics/authentication/#netrc-support[pip documentation for netrc support].
230+
231+
. In your `.tekton/` PipelineRun files, add the newly created secret to the `.spec.workspaces` section:
232+
233+
+
234+
[source,yaml]
235+
----
236+
spec:
237+
# ...
238+
workspaces:
239+
# ...
240+
- name: netrc
241+
secret:
242+
secretName: my-netrc # the name you assigned to the secret in step 1
243+
----
244+
245+
. In the `.spec.pipelineSpec.tasks` section, find the entry with `name: prefetch-dependencies`.
246+
Add the `netrc` workspace to the list of workspaces (if not present):
247+
248+
+
249+
[source,yaml]
250+
----
251+
tasks:
252+
# ...
253+
- name: prefetch-dependencies
254+
# ...
255+
workspaces:
256+
# ...
257+
- name: netrc
258+
workspace: netrc
259+
----
260+
207261
== Enabling prefetch builds for `npm`
208262
Cachi2 supports `npm` by fetching any dependencies you declare in your `package.json` and `package-lock.json` project files. The npm CLI manages the `package-lock.json` file automatically, and Cachi2 fetches any dependencies and enables your build to install them without network access.
209263

0 commit comments

Comments
 (0)