@@ -53,7 +53,7 @@ unchanged dependency set can reuse Docker's installation layer:
5353``` dockerfile
5454ARG PROXY_URL
5555COPY package.json package-lock.json ./
56- RUN npm ci --registry="${PROXY_URL}/npm/"
56+ RUN npm ci --no-audit --no-fund -- registry="${PROXY_URL:?PROXY_URL build arg required }/npm/"
5757COPY . .
5858```
5959
@@ -68,8 +68,8 @@ docker build \
6868Keep ` node_modules ` out of the build context so ` COPY . . ` does not overwrite
6969the installed dependencies. Lockfiles with custom registry or download URLs
7070may still direct requests to those hosts; check proxy's access log when using
71- private registries or non-registry dependencies. npm audit requests are forwarded
72- upstream even when the package archives are cached .
71+ private registries or non-registry dependencies. ` --no- audit` skips the audit
72+ request, which proxy would otherwise forward upstream .
7373
7474## Ruby / Bundler
7575
@@ -80,21 +80,24 @@ native extensions before this step:
8080``` dockerfile
8181ARG PROXY_URL
8282COPY Gemfile Gemfile.lock ./
83- RUN bundle config set --local mirror.https://rubygems.org "${PROXY_URL}/gem" \
83+ RUN bundle config set --local mirror.https://rubygems.org "${PROXY_URL:?PROXY_URL build arg required }/gem" \
8484 && bundle install \
8585 && bundle config unset --local mirror.https://rubygems.org
8686COPY . .
8787```
8888
8989Use the same build command as the npm example. The mirror setting is removed
90- after installation so it is not retained in the image. Exclude host Bundler
90+ after installation so it is not retained in the image, but the URL still
91+ appears in ` docker history ` because Docker records the build args used by ` RUN `
92+ lines. Keep credentials out of ` PROXY_URL ` . Exclude host Bundler
9193configuration and installed gems from the build context. Copy any local path
9294dependencies required by the Gemfile before ` bundle install ` .
9395
9496The RubyGems mirror covers gems fetched from that source. Git dependencies and
95- other gem sources need their own configuration. Bundler can fall back to the
96- original source when a mirror is unavailable; this setup does not enforce
97- network isolation.
97+ other gem sources need their own configuration. Without
98+ ` mirror.https://rubygems.org.fallback_timeout ` , ` bundle install ` fails if proxy
99+ is unreachable. Setting it lets Bundler fall back to rubygems.org, so this setup
100+ does not enforce network isolation either way.
98101
99102## Layer caches and package caches
100103
@@ -105,7 +108,7 @@ be rebuilt. For example, the npm step can use:
105108
106109``` dockerfile
107110RUN --mount=type=cache,target=/root/.npm \
108- npm ci --registry="${PROXY_URL}/npm/"
111+ npm ci --no-audit --no-fund -- registry="${PROXY_URL:?PROXY_URL build arg required }/npm/"
109112```
110113
111114Cache mounts are stored by the builder and are excluded from ordinary
@@ -118,7 +121,7 @@ To check the configuration, enable proxy's JSONL log with `-access-log` and
118121rebuild with ` docker build --no-cache ` . Look for requests to ` /npm/ ` or ` /gem/ ` ,
119122then repeat and check ` proxy_cache_hits_total ` on ` /metrics ` . Cache mounts still
120123retain their contents with ` --no-cache ` ; omit them when testing proxy cache
121- hits. Upstream metadata revalidation and audit requests can still occur.
124+ hits. Upstream metadata revalidation can still occur.
122125
123126## Base-image pulls
124127
0 commit comments