Skip to content

Commit 947404d

Browse files
committed
add support for building artifacts with custom GOPROXY
Signed-off-by: Tariq Ibrahim <tibrahim@nvidia.com>
1 parent e03ac36 commit 947404d

File tree

7 files changed

+48
-16
lines changed

7 files changed

+48
-16
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
run: echo "version=$(echo $GITHUB_SHA | cut -c1-8)" >> "$GITHUB_OUTPUT"
3636

3737
golang:
38+
secrets: inherit
3839
uses: ./.github/workflows/golang.yaml
3940

4041
image:

.github/workflows/golang.yaml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ name: Golang
1616

1717
on:
1818
workflow_call: {}
19-
pull_request:
20-
types:
21-
- opened
22-
- synchronize
23-
branches:
24-
- main
25-
- release-*
2619

2720
jobs:
2821
check:
@@ -84,7 +77,10 @@ jobs:
8477

8578
build:
8679
name: Build
87-
runs-on: ubuntu-latest
80+
runs-on: linux-amd64-cpu4
81+
permissions:
82+
contents: read
83+
id-token: write
8884
steps:
8985
- name: Checkout code
9086
uses: actions/checkout@v5
@@ -100,4 +96,19 @@ jobs:
10096
with:
10197
go-version: ${{ env.GOLANG_VERSION }}
10298

103-
- run: make build
99+
- name: Setup JFrog CLI
100+
id: jfrog
101+
uses: jfrog/setup-jfrog-cli@v4
102+
env:
103+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
104+
with:
105+
oidc-provider-name: nvgithub
106+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
107+
- env:
108+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
109+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
110+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
111+
run: |
112+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
113+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
114+
make build

.github/workflows/image.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ jobs:
7676
path: ${{ github.workspace }}/dist/*
7777

7878
image:
79-
runs-on: ubuntu-latest
79+
runs-on: linux-amd64-cpu4
80+
permissions:
81+
contents: read
82+
id-token: write
83+
packages: write
8084
strategy:
8185
matrix:
8286
target:
@@ -109,12 +113,26 @@ jobs:
109113
username: ${{ github.actor }}
110114
password: ${{ secrets.GITHUB_TOKEN }}
111115

116+
- name: Setup JFrog CLI
117+
id: jfrog
118+
uses: jfrog/setup-jfrog-cli@v4
119+
env:
120+
JF_URL: https://${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}/
121+
with:
122+
oidc-provider-name: nvgithub
123+
oidc-audience: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
124+
112125
- name: Build image
113126
env:
114127
IMAGE_NAME: ghcr.io/nvidia/container-toolkit
115128
VERSION: ${{ inputs.version }}
116129
PUSH_ON_BUILD: "true"
117130
BUILD_MULTI_ARCH_IMAGES: ${{ inputs.build_multi_arch_images }}
131+
OIDC_USER: ${{ steps.jfrog.outputs.oidc-user }}
132+
OIDC_TOKEN: ${{ steps.jfrog.outputs.oidc-token }}
133+
OIDC_ARTIFACTORY_ENDPOINT: ${{ secrets.OIDC_ARTIFACTORY_ENDPOINT }}
118134
run: |
135+
OIDC_USER_ENCODED=$(python3 -c 'import urllib.parse, os; print(urllib.parse.quote_plus(os.environ["OIDC_USER"]))')
136+
export GOPROXY="https://${OIDC_USER_ENCODED}:${OIDC_TOKEN}@${OIDC_ARTIFACTORY_ENDPOINT}/artifactory/api/go/edge-go-remote-virtual"
119137
echo "${VERSION}"
120138
make -f deployments/container/Makefile build-${{ matrix.target }}

deployments/container/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ RUN set -eux; \
4242
ENV GOPATH=/go
4343
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
4444

45+
ARG GOPROXY=direct
46+
ENV GOPROXY=$GOPROXY
47+
4548
WORKDIR /build
4649
COPY . .
4750

deployments/container/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ DIST_DIR ?= $(CURDIR)/dist
2727
##### Global variables #####
2828
include $(CURDIR)/versions.mk
2929

30+
GOPROXY ?= direct
31+
3032
IMAGE_VERSION := $(VERSION)
3133

3234
IMAGE_TAG ?= $(VERSION)
@@ -88,6 +90,7 @@ $(IMAGE_TARGETS): image-%: $(ARTIFACTS_ROOT)
8890
--build-arg GIT_COMMIT_SHORT="$(GIT_COMMIT_SHORT)" \
8991
--build-arg GIT_BRANCH="$(GIT_BRANCH)" \
9092
--build-arg SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" \
93+
--build-arg GOPROXY="$(GOPROXY)" \
9194
-f $(DOCKERFILE) \
9295
$(CURDIR)
9396

internal/lookup/root/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (r *Driver) Version() (string, error) {
9090
return r.version, nil
9191
}
9292

93-
// GetLibcudaParentDir returns the cached libcuda.so path if possible.
93+
// GetLibcudasoPath returns the cached libcuda.so path if possible.
9494
// If this has not yet been initialized, the path is first detected and then returned.
9595
func (r *Driver) GetLibcudasoPath() (string, error) {
9696
r.Lock()

pkg/nvcdi/driver-nvml.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (l *nvcdilib) newDriverVersionDiscoverer() (discover.Discover, error) {
7575
}
7676

7777
// NewDriverLibraryDiscoverer creates a discoverer for the libraries associated with the specified driver version.
78-
func (l *nvcdilib) NewDriverLibraryDiscoverer(version string, libcudaSoParentDirPath string) (discover.Discover, error) {
78+
func (l *nvcdilib) NewDriverLibraryDiscoverer(version string, libCudaSoParentDirectoryPath string) (discover.Discover, error) {
7979
versionSuffixLibraryMounts, err := l.getVersionSuffixDriverLibraryMounts(version)
8080
if err != nil {
8181
return nil, err
@@ -110,10 +110,6 @@ func (l *nvcdilib) NewDriverLibraryDiscoverer(version string, libcudaSoParentDir
110110
disableDeviceNodeModification := l.hookCreator.Create(DisableDeviceNodeModificationHook)
111111
discoverers = append(discoverers, disableDeviceNodeModification)
112112

113-
libCudaSoParentDirectoryPath, err := l.driver.GetLibcudaParentDir()
114-
if err != nil {
115-
return nil, fmt.Errorf("failed to get libcuda.so parent directory path: %w", err)
116-
}
117113
environmentVariable := &discover.EnvVar{
118114
Name: "NVIDIA_CTK_LIBCUDA_DIR",
119115
Value: libCudaSoParentDirectoryPath,

0 commit comments

Comments
 (0)