Skip to content

Commit c3e1361

Browse files
committed
Use Microsoft public npm proxy when NPM_TOKEN is not set
Dev machines can no longer reach registry.npmjs.org (forbidden), so npm-based image builds failed on the no-token fallback path. Add an explicit else branch to every Dockerfile that configures npm so that, when NPM_TOKEN is not provided, the registry is set to the Microsoft public npm proxy (https://packagefeedproxy.microsoft.io/npm/) instead of leaving npm's default (npmjs.org). The internal-token path is unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7658094a-28a3-439f-bee4-b2f9b15e4a68
1 parent 0c26b14 commit c3e1361

13 files changed

Lines changed: 35 additions & 13 deletions

File tree

src/azurelinux/3.0/net10.0/webassembly/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ RUN tdnf update -y \
1616
ARG NPM_TOKEN
1717

1818
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
19-
# otherwise fall back to the default public registry (public builds have no token).
19+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
2020
RUN if [ -n "$NPM_TOKEN" ]; then \
2121
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
2222
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
23+
else \
24+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
2325
fi
2426

2527
# WebAssembly build needs typescript

src/azurelinux/3.0/net8.0/webassembly/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ RUN tdnf update -y \
1717
ARG NPM_TOKEN
1818

1919
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
20-
# otherwise fall back to the default public registry (public builds have no token).
20+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
2121
RUN if [ -n "$NPM_TOKEN" ]; then \
2222
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
2323
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
24+
else \
25+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
2426
fi
2527

2628
# WebAssembly build needs typescript

src/azurelinux/3.0/net9.0/webassembly/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ RUN tdnf update -y \
1616
ARG NPM_TOKEN
1717

1818
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
19-
# otherwise fall back to the default public registry (public builds have no token).
19+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
2020
RUN if [ -n "$NPM_TOKEN" ]; then \
2121
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
2222
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
23+
else \
24+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
2325
fi
2426

2527
# WebAssembly build needs typescript

src/azurelinux/3.0/renovate/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ RUN tdnf update -y && \
2121
ARG NPM_TOKEN
2222

2323
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
24-
# otherwise fall back to the default public registry (public builds have no token).
24+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
2525
RUN if [ -n "$NPM_TOKEN" ]; then \
2626
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
2727
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
28+
else \
29+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
2830
fi && \
2931
npm install -g renovate@${RENOVATE_VERSION}

src/ubuntu/22.04/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ARG NPM_TOKEN
101101

102102
# Install Node 20 from NodeSource and use the patched npm ip module.
103103
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
104-
# otherwise fall back to the default public registry (public builds have no token).
104+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
105105
RUN cd /etc/apt/sources.list.d && \
106106
rm -f nodesource.list && \
107107
cd ~ && \
@@ -113,6 +113,8 @@ RUN cd /etc/apt/sources.list.d && \
113113
if [ -n "$NPM_TOKEN" ]; then \
114114
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
115115
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
116+
else \
117+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
116118
fi && \
117119
npm install -g ip@latest
118120

src/ubuntu/22.04/coredeps/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ARG NPM_TOKEN
4040

4141
# Install Node 20 from NodeSource and use the patched npm ip module.
4242
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
43-
# otherwise fall back to the default public registry (public builds have no token).
43+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
4444
RUN cd /etc/apt/sources.list.d && \
4545
rm -f nodesource.list && \
4646
cd ~ && \
@@ -52,5 +52,7 @@ RUN cd /etc/apt/sources.list.d && \
5252
if [ -n "$NPM_TOKEN" ]; then \
5353
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
5454
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
55+
else \
56+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
5557
fi && \
5658
npm install -g ip@latest

src/ubuntu/22.04/helix/webassembly/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ RUN /tmp/setup-node-23.x.sh && apt-get -y install nodejs
4444
ARG NPM_TOKEN
4545

4646
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
47-
# otherwise fall back to the default public registry (public builds have no token).
47+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
4848
RUN if [ -n "$NPM_TOKEN" ]; then \
4949
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
5050
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
51+
else \
52+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
5153
fi && \
5254
npm install -g npm
5355

src/ubuntu/24.04/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ARG NPM_TOKEN
100100

101101
# Install node 20 and use its bundled npm so we don't pull in distro npm dependencies unnecessarily.
102102
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
103-
# otherwise fall back to the default public registry (public builds have no token).
103+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
104104
RUN rm -f /etc/apt/sources.list.d/nodesource.list && \
105105
cd ~ && \
106106
curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh && \
@@ -111,6 +111,8 @@ RUN rm -f /etc/apt/sources.list.d/nodesource.list && \
111111
if [ -n "$NPM_TOKEN" ]; then \
112112
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
113113
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
114+
else \
115+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
114116
fi && \
115117
npm install -g ip@latest
116118

src/ubuntu/24.04/helix/webassembly/amd64/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ RUN chmod +x /tmp/setup-node-23.x.sh \
4949
ARG NPM_TOKEN
5050

5151
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
52-
# otherwise fall back to the default public registry (public builds have no token).
52+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
5353
RUN if [ -n "$NPM_TOKEN" ]; then \
5454
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
5555
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
56+
else \
57+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
5658
fi && \
5759
npm install -g npm
5860

src/ubuntu/26.04/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ARG NPM_TOKEN
101101

102102
# Install node 20 and use its bundled npm so we don't pull in distro npm dependencies unnecessarily.
103103
# When NPM_TOKEN is provided (internal builds) use the dotnet-public-npm Azure Artifacts feed;
104-
# otherwise fall back to the default public registry (public builds have no token).
104+
# otherwise fall back to the Microsoft public npm proxy (public builds have no token).
105105
RUN rm -f /etc/apt/sources.list.d/nodesource.list && \
106106
cd ~ && \
107107
curl -sL https://deb.nodesource.com/setup_20.x -o nodesource_setup.sh && \
@@ -112,6 +112,8 @@ RUN rm -f /etc/apt/sources.list.d/nodesource.list && \
112112
if [ -n "$NPM_TOKEN" ]; then \
113113
npm config set registry https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ && \
114114
npm config set "//pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/:_authToken" "$NPM_TOKEN"; \
115+
else \
116+
npm config set registry https://packagefeedproxy.microsoft.io/npm/; \
115117
fi && \
116118
npm install -g ip@latest
117119

0 commit comments

Comments
 (0)