JavaScript and npm package consumption in a large organization is typically
managed by a repository manager. Commonly used repository manager applications
are JFrog Artifactory, Sonatype Nexus
Repository, and
others. The repository manager acts as a single point of access for developers
and development tools to retrieve the required libraries.
At a high level, adopting the use of Chainguard Libraries consists of the
following steps:
Add the Chainguard Libraries for JavaScript registry as a remote repository
for library retrieval.
Configure the repository as the first choice for any library access. This
ensures that any future requests of new libraries access the version supplied
by Chainguard. Typically this is accomplished by creating a group repository
or virtual repository that combines the repository with other external and
internal repositories.
Additional steps depend on the desired insights and can include the following
optional measures:
Remove all cached libraries in the proxy repository of the npm Registry. This
step allows you to validate which libraries are not available from Chainguard
Libraries and proceed with potential next steps with Chainguard and your own
development efforts.
Remove any repositories that are no longer desired or necessary. Depending on
your library requirements this step can result in removal of some proxy
repositories or even removal of all proxy repositories.
Adopting the use of a repository manager is the recommended approach, however if
your organization does not use a repository manager, you can still use
Chainguard Libraries. All access to the Chainguard Libraries repository is then
distributed across all your build platforms and therefore more complex to
configure and control. Refer to the direct access documentation for build
tools for more
information.
Use the following steps to add the npm Registry and the Chainguard Libraries for
JavaScript repository as remote repositories and combine them as a virtual
repository:
Log in as a user with administrator privileges.
Press Administration in the top navigation bar.
Select Repositories in the left hand navigation.
Configure a remote repository for the npm Registry:
Press Create a Repository and choose the Remote option.
Select Npm as the Package type.
Set the Repository Key to javascript-public.
Set the URL to https://registry.npmjs.org .
Press Create Remote Repository.
Configure a remote repository for the Chainguard Libraries for JavaScript
repository:
Press Create a Repository and choose the Remote option.
Select Npm as the Package type.
Set the Repository Key to javascript-chainguard.
Set the URL to https://libraries.cgr.dev/javascript/.
Combine the two repositories in a new virtual repository:
Press Create a Repository and choose the Virtual option.
Select Npm as the Package type.
Set the Repository Key to javascript-all.
Scroll down to the Repositories section.
Add the javascript-chainguard and javascript-public repositories. Ensure
the javascript-chainguard repository is the first in the displayed list.
Use the icon on the right of the repository name to drag and drop
repositories into the desired position.
Press Create Virtual Repository.
Use this setup for initial testing with Chainguard Libraries for JavaScript. For
production usage add the javascript-chainguard repository to your production
virtual repository.
Build tool access
The following steps allow you to determine the URL and authentication details
for accessing the repository:
Press Administration in the top navigation bar.
Select Repositories in the left hand navigation.
Select the Virtual tab in the repositories view.
Locate the javascript-all repository.
Hover over the row and click the … in the last column on the right.
Select Set Me Up in the dialog.
Press Generate Token & Create Instructions.
Copy the generated token value to use as the password for authentication.
Press Generate Settings.
Copy the value from a url field. The are all identical. For example,
https://exampleorg.jfrog.io/artifactory/javascript-all/ with exampleorg
replaced with the name of your organization.
Use the URL of the virtual repository in the build
configuration and build a
first test project. In a working setup the chainguard remote repository contains
all libraries retrieved from Chainguard.
For initial testing and adoption it is advised to create a separate proxy
repository for the npm registry, a separate proxy repository Chainguard
Libraries for JavaScript repository, and a separate repository group:
Log in as a user with administrator privileges.
Access the Server administration and configuration section with the gear
icon in the top navigation bar.
Configure a remote repository for the npm Registry:
Select Repository - Repositories in the left hand navigation.
Press Create repository.
Select the npm (proxy) recipe.
Provide a new name javascript-public.
In the Proxy - Remote storage input add the URL
https://registry.npmjs.org/.
Press Create repository.
Configure a remote repository for the Chainguard Libraries for JavaScript
repository:
Select Repository - Repositories in the left hand navigation.
Press Create repository.
Select the npm (proxy) recipe.
Provide a new name javascript-chainguard.
In the Proxy - Remote storage input add the URL
https://libraries.cgr.dev/javascript/.
Combine a new repository group and add the two repositories:
Select Repository - Repositories in the left hand navigation.
Press Create repository.
Select the npm (group) recipe.
Provide a new name javascript-all.
In the section Group - Member repositories, move the new repositories
javascript-public and javascript-chainguard to the right and move the
javascript-chainguard repository to the top of the list with the arrow
control.
Build tool access
The following steps allow you to determine the URL and authentication details
for accessing the repository:
Click Browse in the Welcome view or the browse icon (cube) in the top
navigation bar.
Locate the URL column for the javascript-all repository group and press
copy. For example, https://repo.example.com/repository/javascript-all/
with repo.example.com replaced with the hostname of you repository manager.
Copy the URL in the dialog.
Use your configured username and password unless Security - Anonymous
Access - Access - Allow anonymous users to access the server is
activated. Details vary based on your configured authentication system.
Use the URL of the repository group, such as
https://repo.example.com/repository/javascript-all/ in the build
configuration and build a
first test project. In a working setup the javascript-chainguard proxy
repository contains all libraries retrieved from Chainguard.