Skip to content

Commit 2d218bb

Browse files
committed
update
1 parent e621e6d commit 2d218bb

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

docs/platforms/jfrog.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ terraform {
4747
4848
variable "jfrog_url" {
4949
type = string
50-
description = "The URL of the JFrog instance."
50+
description = "The URL of the JFrog instance. e.g. YYY.jfrog.io"
5151
}
5252
5353
variable "artifactory_access_token" {
@@ -143,7 +143,7 @@ Distribution URL: https://cdr.jfrog.io/distribution/
143143
Xray URL: https://cdr.jfrog.io/xray/
144144
Mission Control URL: https://cdr.jfrog.io/mc/
145145
Pipelines URL: https://cdr.jfrog.io/pipelines/
146-
User: ammar
146+
User: ammar@....com
147147
Access token: ...
148148
Default: true
149149
```

examples/templates/jfrog-docker/build/Dockerfile

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ RUN apt-get update \
44
&& apt-get install -y \
55
curl \
66
git \
7-
golang \
87
python3-pip \
98
sudo \
109
vim \
1110
wget \
1211
npm \
1312
&& rm -rf /var/lib/apt/lists/*
1413

14+
ARG GO_VERSION=1.20.7
15+
RUN mkdir --parents /usr/local/go && curl --silent --show-error --location \
16+
"https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -o /usr/local/go.tar.gz && \
17+
tar --extract --gzip --directory=/usr/local/go --file=/usr/local/go.tar.gz --strip-components=1
18+
19+
ENV PATH=$PATH:/usr/local/go/bin
20+
1521
ARG USER=coder
1622
RUN useradd --groups sudo --no-create-home --shell /bin/bash ${USER} \
1723
&& echo "${USER} ALL=(ALL) NOPASSWD:ALL" >/etc/sudoers.d/${USER} \

examples/templates/jfrog-docker/main.tf

+15-11
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,23 @@ terraform {
1616
}
1717

1818
locals {
19-
username = data.coder_workspace.me.owner
19+
# if the jfrog username is same as the coder username, you can use the following
20+
# username = data.coder_workspace.me.owner
21+
# if the username is same as email, you can use the following
22+
# username = urlencode(data.coder_workspace.me.owner_email)
23+
artifactory_username = data.coder_workspace.me.owner
2024
artifactory_registry_keys = {
21-
"npm" = "npm"
22-
"pypi" = "pypi"
23-
"go" = "go"
25+
"npm" = "npm"
26+
"python" = "python"
27+
"go" = "go"
2428
}
29+
workspace_user = data.coder_workspace.me.owner
2530
}
2631

2732
data "coder_provisioner" "me" {
2833
}
2934

3035
provider "docker" {
31-
host = "tcp://100.117.102.81:2375"
3236
}
3337

3438
data "coder_workspace" "me" {
@@ -51,7 +55,7 @@ provider "artifactory" {
5155
}
5256

5357
resource "artifactory_scoped_token" "me" {
54-
username = data.coder_workspace.me.owner
58+
username = local.artifactory_username
5559
}
5660

5761
resource "coder_agent" "main" {
@@ -84,21 +88,21 @@ resource "coder_agent" "main" {
8488
mkdir -p ~/.pip
8589
cat << EOF > ~/.pip/pip.conf
8690
[global]
87-
index-url = https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_url}/artifactory/api/pypi/${local.artifactory_registry_keys["pypi"]}/simple
91+
index-url = https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_url}/artifactory/api/pypi/${local.artifactory_registry_keys["python"]}/simple
8892
EOF
8993
9094
EOT
9195
# Set GOPROXY to use the Artifactory "go" registry.
9296
env = {
93-
GOPROXY : "https://${data.coder_workspace.me.owner}:${artifactory_scoped_token.me.access_token}@${var.jfrog_url}/artifactory/api/go/${local.artifactory_registry_keys["go"]}"
97+
GOPROXY : "https://${local.artifactory_username}:${artifactory_scoped_token.me.access_token}@${var.jfrog_url}/artifactory/api/go/${local.artifactory_registry_keys["go"]}"
9498
}
9599
}
96100

97101
resource "coder_app" "code-server" {
98102
agent_id = coder_agent.main.id
99103
slug = "code-server"
100104
display_name = "code-server"
101-
url = "http://localhost:13337/?folder=/home/${local.username}"
105+
url = "http://localhost:13337/?folder=/home/${local.workspace_user}"
102106
icon = "/icon/code.svg"
103107
subdomain = false
104108
share = "owner"
@@ -123,7 +127,7 @@ resource "docker_image" "main" {
123127
build {
124128
context = "./build"
125129
build_args = {
126-
USER = local.username
130+
USER = local.workspace_user
127131
}
128132
}
129133
triggers = {
@@ -145,7 +149,7 @@ resource "docker_container" "workspace" {
145149
ip = "host-gateway"
146150
}
147151
volumes {
148-
container_path = "/home/${local.username}"
152+
container_path = "/home/${local.workspace_user}"
149153
volume_name = docker_volume.home_volume.name
150154
read_only = false
151155
}

0 commit comments

Comments
 (0)