mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
refactor: refactor JFrog docs and template (#11336)
This commit is contained in:
@@ -5,7 +5,7 @@ tags: [local, docker, jfrog]
|
||||
icon: /icon/docker.png
|
||||
---
|
||||
|
||||
# docker
|
||||
# Docker
|
||||
|
||||
To get started, run `coder templates init`. When prompted, select this template.
|
||||
Follow the on-screen instructions to proceed.
|
||||
@@ -22,5 +22,5 @@ the dashboard UI over `localhost:13337`.
|
||||
|
||||
# Next steps
|
||||
|
||||
Check out our [Docker](../docker/) template for a more fully featured Docker
|
||||
Check out our [Docker](../../templates/docker/) template for a more fully featured Docker
|
||||
example.
|
||||
|
||||
@@ -13,8 +13,8 @@ terraform {
|
||||
}
|
||||
|
||||
locals {
|
||||
# take care to use owner_email instead of owner because users can change
|
||||
# their username.
|
||||
# Make sure to use the same field as the username field in the Artifactory
|
||||
# It can be either the username or the email address.
|
||||
artifactory_username = data.coder_workspace.me.owner_email
|
||||
artifactory_repository_keys = {
|
||||
"npm" = "npm"
|
||||
@@ -22,31 +22,34 @@ locals {
|
||||
"go" = "go"
|
||||
}
|
||||
workspace_user = data.coder_workspace.me.owner
|
||||
jfrog_host = replace(var.jfrog_url, "^https://", "")
|
||||
}
|
||||
|
||||
data "coder_provisioner" "me" {
|
||||
}
|
||||
data "coder_provisioner" "me" {}
|
||||
|
||||
provider "docker" {
|
||||
}
|
||||
provider "docker" {}
|
||||
|
||||
data "coder_workspace" "me" {
|
||||
}
|
||||
data "coder_workspace" "me" {}
|
||||
|
||||
variable "jfrog_host" {
|
||||
variable "jfrog_url" {
|
||||
type = string
|
||||
description = "JFrog instance hostname. For example, 'YYY.jfrog.io'."
|
||||
description = "JFrog instance URL. For example, https://jfrog.example.com."
|
||||
# validate the URL to ensure it starts with https:// or http://
|
||||
validation {
|
||||
condition = can(regex("^https?://", var.jfrog_url))
|
||||
error_message = "JFrog URL must start with https:// or http://"
|
||||
}
|
||||
}
|
||||
|
||||
variable "artifactory_access_token" {
|
||||
variable "artifactory_admin_access_token" {
|
||||
type = string
|
||||
description = "The admin-level access token to use for JFrog."
|
||||
description = "The admin-level access token to use for JFrog with scope applied-permissions/admin."
|
||||
}
|
||||
|
||||
# Configure the Artifactory provider
|
||||
# Configure the Artifactory provider with the admin-level access token.
|
||||
provider "artifactory" {
|
||||
url = "https://${var.jfrog_host}/artifactory"
|
||||
access_token = var.artifactory_access_token
|
||||
url = "${var.jfrog_url}/artifactory"
|
||||
access_token = var.artifactory_admin_access_token
|
||||
}
|
||||
|
||||
resource "artifactory_scoped_token" "me" {
|
||||
@@ -63,7 +66,7 @@ resource "coder_agent" "main" {
|
||||
set -e
|
||||
|
||||
# install and start code-server
|
||||
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0
|
||||
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server
|
||||
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
|
||||
|
||||
# Install the JFrog VS Code extension.
|
||||
@@ -77,12 +80,12 @@ resource "coder_agent" "main" {
|
||||
|
||||
jf c rm 0 || true
|
||||
echo ${artifactory_scoped_token.me.access_token} | \
|
||||
jf c add --access-token-stdin --url https://${var.jfrog_host} 0
|
||||
jf c add --access-token-stdin --url ${var.jfrog_url} 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"]}
|
||||
registry = ${var.jfrog_url}/artifactory/api/npm/${local.artifactory_repository_keys["npm"]}
|
||||
EOF
|
||||
jf rt curl /api/npm/auth >> .npmrc
|
||||
|
||||
@@ -90,15 +93,15 @@ resource "coder_agent" "main" {
|
||||
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
|
||||
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.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"]}"
|
||||
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${local.jfrog_host}/artifactory/api/go/${local.artifactory_repository_keys["go"]}"
|
||||
# Authenticate with JFrog extension.
|
||||
JFROG_IDE_URL : "https://${var.jfrog_host}"
|
||||
JFROG_IDE_URL : "${var.jfrog_url}"
|
||||
JFROG_IDE_USERNAME : "${local.artifactory_username}"
|
||||
JFROG_IDE_PASSWORD : "${artifactory_scoped_token.me.access_token}"
|
||||
JFROG_IDE_ACCESS_TOKEN : "${artifactory_scoped_token.me.access_token}"
|
||||
|
||||
Reference in New Issue
Block a user