-
Notifications
You must be signed in to change notification settings - Fork 928
docs: expand jfrog platform and example template #9073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
da09fbd
dcs: update jfrog package management docs
matifali e621e6d
fmt
matifali 2d218bb
update
matifali f4ce485
rename `jfrog_host` to `jfrog_url`
matifali 86926f5
typo
matifali e4b4f2f
Merge branch 'main' into jfrog-pkg-manager-docs
matifali dda579e
update docs
matifali 043392f
obfuscate
matifali 19ca292
incorporate suggestions
matifali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ The full example template can be found [here](https://github.com/coder/coder/tre | |
|
||
- A JFrog Artifactory instance | ||
- An admin-level access token for Artifactory | ||
- 1:1 mapping of users in Coder to users in Artifactory by email address | ||
- An npm repository in Artifactory named "npm" | ||
- 1:1 mapping of users in Coder to users in Artifactory by email address and username | ||
- Repositories configured in Artifactory for each package manager you want to use | ||
|
||
<blockquote class="info"> | ||
The admin-level access token is used to provision user tokens and is never exposed to | ||
|
@@ -40,14 +40,14 @@ terraform { | |
} | ||
artifactory = { | ||
source = "registry.terraform.io/jfrog/artifactory" | ||
version = "6.22.3" | ||
version = "~> 8.4.0" | ||
} | ||
} | ||
} | ||
|
||
variable "jfrog_url" { | ||
variable "jfrog_host" { | ||
type = string | ||
description = "The URL of the JFrog instance." | ||
description = "JFrog instance hostname. e.g. YYY.jfrog.io" | ||
} | ||
|
||
variable "artifactory_access_token" { | ||
|
@@ -57,15 +57,15 @@ variable "artifactory_access_token" { | |
|
||
# Configure the Artifactory provider | ||
provider "artifactory" { | ||
url = "${var.jfrog_url}/artifactory" | ||
url = "https://${var.jfrog_host}/artifactory" | ||
access_token = "${var.artifactory_access_token}" | ||
} | ||
``` | ||
|
||
When pushing the template, you can pass in the variables using the `-V` flag: | ||
When pushing the template, you can pass in the variables using the `--var` flag: | ||
|
||
```sh | ||
coder templates push --var 'jfrog_url=https://YYY.jfrog.io' --var 'artifactory_access_token=XXX' | ||
coder templates push --var 'jfrog_host=YYY.jfrog.io' --var 'artifactory_access_token=XXX' | ||
``` | ||
|
||
## Installing JFrog CLI | ||
|
@@ -88,7 +88,21 @@ In our Docker-based example, we install `jf` by adding these lines to our `Docke | |
RUN curl -fL https://install-cli.jfrog.io | sh && chmod 755 $(which jf) | ||
``` | ||
|
||
and use this `coder_agent` block: | ||
## Configuring Coder workspace to use JFrog Artifactory repositories | ||
|
||
Create a `locals` block to store the Artifactory repository keys for each package manager you want to use in your workspace. For example, if you want to use artifactory repositories with keys `npm`, `pypi`, and `go`, you can create a `locals` block like this: | ||
|
||
```hcl | ||
locals { | ||
artifactory_repository_keys = { | ||
npm = "npm" | ||
python = "pypi" | ||
go = "go" | ||
} | ||
} | ||
``` | ||
|
||
To automatically configure `jf` CLI and Artifactory repositories for each user, add the following lines to your `startup_script` in the `coder_agent` block: | ||
|
||
```hcl | ||
resource "coder_agent" "main" { | ||
|
@@ -107,9 +121,28 @@ resource "coder_agent" "main" { | |
export CI=true | ||
|
||
jf c rm 0 || true | ||
echo ${artifactory_access_token.me.access_token} | \ | ||
jf c add --access-token-stdin --url ${var.jfrog_url} 0 | ||
echo ${artifactory_scoped_token.me.access_token} | \ | ||
jf c add --access-token-stdin --url https://${var.jfrog_host} 0 | ||
|
||
# Configure the `npm` CLI to use the Artifactory "npm" repository. | ||
cat << EOF > ~/.npmrc | ||
email = ${data.coder_workspace.me.owner_email} | ||
registry = https://${var.jfrog_host}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]} | ||
EOF | ||
jf rt curl /api/npm/auth >> .npmrc | ||
|
||
# Configure the `pip` to use the Artifactory "python" repository. | ||
mkdir -p ~/.pip | ||
cat << EOF > ~/.pip/pip.conf | ||
[global] | ||
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/${local.artifactory_repository_keys["python"]}/simple | ||
EOF | ||
|
||
EOT | ||
# Set GOPROXY to use the Artifactory "go" repository. | ||
env = { | ||
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}" | ||
} | ||
} | ||
``` | ||
|
||
|
@@ -119,12 +152,12 @@ running `jf c show`. It should display output like: | |
```text | ||
coder@jf:~$ jf c show | ||
Server ID: 0 | ||
JFrog Platform URL: https://cdr.jfrog.io/ | ||
Artifactory URL: https://cdr.jfrog.io/artifactory/ | ||
Distribution URL: https://cdr.jfrog.io/distribution/ | ||
Xray URL: https://cdr.jfrog.io/xray/ | ||
Mission Control URL: https://cdr.jfrog.io/mc/ | ||
Pipelines URL: https://cdr.jfrog.io/pipelines/ | ||
JFrog Platform URL: https://YYY.jfrog.io/ | ||
Artifactory URL: https://YYY.jfrog.io/artifactory/ | ||
Distribution URL: https://YYY.jfrog.io/distribution/ | ||
Xray URL: https://YYY.jfrog.io/xray/ | ||
Mission Control URL: https://YYY.jfrog.io/mc/ | ||
Pipelines URL: https://YYY.jfrog.io/pipelines/ | ||
User: [email protected] | ||
Access token: ... | ||
Default: true | ||
|
@@ -151,11 +184,11 @@ Note that this method will only work if your developers use code-server. | |
Add the following line to your `startup_script` to configure `npm` to use | ||
Artifactory: | ||
|
||
```sh | ||
```shell | ||
# Configure the `npm` CLI to use the Artifactory "npm" registry. | ||
cat << EOF > ~/.npmrc | ||
email = ${data.coder_workspace.me.owner_email} | ||
registry=${var.jfrog_url}/artifactory/api/npm/npm/ | ||
registry = https://${var.jfrog_host}/artifactory/api/npm/npm/ | ||
EOF | ||
jf rt curl /api/npm/auth >> .npmrc | ||
``` | ||
|
@@ -165,8 +198,33 @@ use Artifactory as the package registry. You can verify that `npm` is configured | |
correctly by running `npm install --loglevel=http react` and checking that | ||
npm is only hitting your Artifactory URL. | ||
|
||
You can apply the same concepts to Docker, Go, Maven, and other package managers | ||
supported by Artifactory. | ||
## Configuring pip | ||
|
||
Add the following lines to your `startup_script` to configure `pip` to use | ||
Artifactory: | ||
|
||
```shell | ||
mkdir -p ~/.pip | ||
cat << EOF > ~/.pip/pip.conf | ||
[global] | ||
index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/pypi/pypi/simple | ||
matifali marked this conversation as resolved.
Show resolved
Hide resolved
|
||
EOF | ||
``` | ||
|
||
Now, your developers can run `pip install` and transparently use Artifactory as the package registry. You can verify that `pip` is configured correctly by running `pip install --verbose requests` and checking that pip is only hitting your Artifactory URL. | ||
|
||
## Configuring Go | ||
|
||
Add the following environment variable to your `coder_agent` block to configure `go` to use Artifactory: | ||
|
||
```hcl | ||
env = { | ||
GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_host}/artifactory/api/go/go" | ||
matifali marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
``` | ||
|
||
You can apply the same concepts to Docker, Maven, and other package managers | ||
supported by Artifactory. See the [JFrog documentation](https://jfrog.com/help/r/jfrog-artifactory-documentation/package-management) for more information. | ||
|
||
## More reading | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.