-
Notifications
You must be signed in to change notification settings - Fork 70
AGENT-1261: Update dependency sourcing to remote #3152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
dc80696
534f5be
987f5f2
89f4ae7
e4669cb
028616f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,19 +1,49 @@ | ||||||||||||||||||||||||||||||||||||||
| FROM registry.ci.openshift.org/ocp/builder:rhel-9-base-nodejs-openshift-4.19 AS ui-build | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # The REMOTE_SOURCES value is set by the build system to indicate the location of the cachito-backed artifacts cache. | ||||||||||||||||||||||||||||||||||||||
| # As cachito might not be available in all environments, we need to make sure the value is set before trying to use it and | ||||||||||||||||||||||||||||||||||||||
| # that the COPY layer below doesn't fail. Setting it to be the Dockerfile itself is fairly safe, as it will always be | ||||||||||||||||||||||||||||||||||||||
| # available. | ||||||||||||||||||||||||||||||||||||||
| ARG REMOTE_SOURCES | ||||||||||||||||||||||||||||||||||||||
| ARG REMOTE_SOURCES_DIR=/remote-sources | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||
| USER root | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||
| COPY --chown=1001:0 / /app | ||||||||||||||||||||||||||||||||||||||
| RUN ls /app | ||||||||||||||||||||||||||||||||||||||
| COPY --chown=1001:0 . /app | ||||||||||||||||||||||||||||||||||||||
| ENV NODE_OPTIONS='--max-old-space-size=8192' | ||||||||||||||||||||||||||||||||||||||
| RUN git config --global --add safe.directory /app | ||||||||||||||||||||||||||||||||||||||
| RUN npm install -g corepack@0.24.1 | ||||||||||||||||||||||||||||||||||||||
|
pawanpinjarkar marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||
| RUN yarn install --immutable && yarn build:all | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # bootstrap yarn so we can install and run the other tools. | ||||||||||||||||||||||||||||||||||||||
| USER 0 | ||||||||||||||||||||||||||||||||||||||
| ARG YARN_VERSION=v3.4.1 | ||||||||||||||||||||||||||||||||||||||
| RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \ | ||||||||||||||||||||||||||||||||||||||
| if [ -f ${CACHED_YARN} ]; then \ | ||||||||||||||||||||||||||||||||||||||
| npm install -g ${CACHED_YARN}; \ | ||||||||||||||||||||||||||||||||||||||
| else \ | ||||||||||||||||||||||||||||||||||||||
| echo "need yarn at ${CACHED_YARN}"; \ | ||||||||||||||||||||||||||||||||||||||
|
pawanpinjarkar marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||
| exit 1; \ | ||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusiveYarn bootstrap likely incorrect for Yarn 3; clarify target and use an offline-safe flow If the intent is Yarn 3, installing via Option A — Yarn 3 (offline, via local .cjs): -ARG YARN_VERSION=v3.4.1
-RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \
- if [ -f ${CACHED_YARN} ]; then \
- npm install -g ${CACHED_YARN}; \
- else \
- echo "need yarn at ${CACHED_YARN}"; \
- exit 1; \
- fi
+ARG YARN_VERSION=3.4.1
+RUN YARN_CJS=./artifacts/yarn-${YARN_VERSION}.cjs; \
+ if [ -f "${YARN_CJS}" ]; then \
+ node "${YARN_CJS}" --version; \
+ else \
+ echo "need yarn at ${YARN_CJS}"; \
+ exit 1; \
+ fi
@@
- && yarn install --immutable && yarn build:all
+ && node "./artifacts/yarn-${YARN_VERSION}.cjs" install --immutable \
+ && node "./artifacts/yarn-${YARN_VERSION}.cjs" build:allOption B — Yarn 1 (classic, offline tarball from npm): -ARG YARN_VERSION=v3.4.1
+ARG YARN_VERSION=1.22.22
-RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \
- if [ -f ${CACHED_YARN} ]; then \
- npm install -g ${CACHED_YARN}; \
+RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tgz; \
+ if [ -f "${CACHED_YARN}" ]; then \
+ npm install -g "${CACHED_YARN}"; \
else \
echo "need yarn at ${CACHED_YARN}"; \
exit 1; \
fi
@@
- && yarn install --immutable && yarn build:all
+ && yarn install --frozen-lockfile && yarn build:allAlso applies to: 33-34 Clarify Yarn version and use offline-safe installation The current bootstrap uses Option A — Yarn 3 via single - ARG YARN_VERSION=v3.4.1
- RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \
- if [ -f ${CACHED_YARN} ]; then \
- npm install -g ${CACHED_YARN}; \
+ ARG YARN_VERSION=3.4.1
+ RUN YARN_CJS=./artifacts/yarn-${YARN_VERSION}.cjs; \
+ if [ -f "${YARN_CJS}" ]; then \
+ node "${YARN_CJS}" --version; \
else \
echo "need yarn at ${YARN_CJS}"; \
exit 1; \
fi
@@
- && yarn install --immutable && yarn build:all
+ && node "./artifacts/yarn-${YARN_VERSION}.cjs" install --immutable \
+ && node "./artifacts/yarn-${YARN_VERSION}.cjs" build:all• Yarn 3 releases are distributed as Option B — Yarn 1 (Classic) via - ARG YARN_VERSION=v3.4.1
+ ARG YARN_VERSION=1.22.22
- RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \
- if [ -f ${CACHED_YARN} ]; then \
- npm install -g ${CACHED_YARN}; \
+ RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tgz; \
+ if [ -f "${CACHED_YARN}" ]; then \
+ npm install -g "${CACHED_YARN}"; \
else \
echo "need yarn at ${CACHED_YARN}"; \
exit 1; \
fi
@@
- && yarn install --immutable && yarn build:all
+ && yarn install --frozen-lockfile && yarn build:all• Yarn 1 publishes as Also apply these changes around lines 33–34. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # use dependencies provided by Cachito | ||||||||||||||||||||||||||||||||||||||
| RUN test -d ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps || exit 1; \ | ||||||||||||||||||||||||||||||||||||||
| cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/{.npmrc,.yarnrc,yarn.lock,registry-ca.pem} . \ | ||||||||||||||||||||||||||||||||||||||
|
pawanpinjarkar marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||
| && source ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env \ | ||||||||||||||||||||||||||||||||||||||
| && yarn install --immutable && yarn build:all | ||||||||||||||||||||||||||||||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
Comment on lines
+33
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainAlign dependency files and install flags with chosen Yarn major; avoid brittle brace copy
Option A — Yarn 3: -RUN test -d ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps || exit 1; \
- cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/{.npmrc,.yarnrc,yarn.lock,registry-ca.pem} . \
- && . ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env \
- && yarn install --immutable && yarn build:all
+RUN set -euo pipefail; \
+ test -d "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps" || exit 1; \
+ for f in .npmrc yarn.lock yarnrc.yml registry-ca.pem; do \
+ [ -f "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/${f}" ] && \
+ cp -f "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/${f}" . || true; \
+ done; \
+ yarn install --immutable && yarn build:allOption B — Yarn 1: -RUN test -d ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps || exit 1; \
- cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/{.npmrc,.yarnrc,yarn.lock,registry-ca.pem} . \
- && . ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env \
- && yarn install --immutable && yarn build:all
+RUN set -euo pipefail; \
+ test -d "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps" || exit 1; \
+ for f in .npmrc .yarnrc yarn.lock registry-ca.pem; do \
+ [ -f "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/${f}" ] && \
+ cp -f "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/${f}" . || true; \
+ done; \
+ yarn install --frozen-lockfile && yarn build:all🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1. List Yarn config files to detect .yarnrc vs .yarnrc.yml
find . -maxdepth 3 -type f -name ".yarnrc*" -print
# 2. Inspect package.json for packageManager field (Node 16+ spec for Yarn)
rg -n '"packageManager"' -g 'package.json' || true
# 3. Scan for yarn install invocations to see which flags are already used
rg -n 'yarn install' -n .Length of output: 845 Use Yarn 3 config and guard missing files when copying Cachito deps -RUN test -d ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps || exit 1; \
- cp -f $REMOTE_SOURCES_DIR/cachito-gomod-with-deps/app/{.npmrc,.yarnrc,yarn.lock,registry-ca.pem} . \
- && . ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env \
- && yarn install --immutable && yarn build:all
+RUN set -euo pipefail; \
+ test -d "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps" || exit 1; \
+ for f in .npmrc yarn.lock .yarnrc.yml registry-ca.pem; do \
+ [ -f "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/${f}" ] && \
+ cp -f "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/${f}" .; \
+ done; \
+ . "${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env"; \
+ yarn install --immutable && yarn build:all📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.23-openshift-4.19 as proxy-build | ||||||||||||||||||||||||||||||||||||||
| ARG REMOTE_SOURCES_DIR=/remote-sources | ||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||
| COPY apps/assisted-disconnected-ui/proxy /app | ||||||||||||||||||||||||||||||||||||||
| # Use Cachito-provided source + deps for offline build | ||||||||||||||||||||||||||||||||||||||
| COPY --from=ui-build ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/ /app | ||||||||||||||||||||||||||||||||||||||
| USER 0 | ||||||||||||||||||||||||||||||||||||||
| RUN go build | ||||||||||||||||||||||||||||||||||||||
| # Build deterministically and name the output explicitly | ||||||||||||||||||||||||||||||||||||||
| ENV CGO_ENABLED=0 | ||||||||||||||||||||||||||||||||||||||
| RUN source ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env; \ | ||||||||||||||||||||||||||||||||||||||
| if [ -d vendor ]; then export GOFLAGS="-mod=vendor"; fi; \ | ||||||||||||||||||||||||||||||||||||||
| go build -o assisted-disconnected-ui . | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion proxy-build sources cachito.env without copying it into this stage Only /app is copied from ui-build; /remote-sources/.../cachito.env is missing, so “source …/cachito.env” will fail. COPY --from=ui-build ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/app/ /app
+COPY --from=ui-build ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env /tmp/cachito.env
@@
-RUN source ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env; \
+RUN . /tmp/cachito.env; \
if [ -d vendor ]; then export GOFLAGS="-mod=vendor"; fi; \
go build -o assisted-disconnected-ui .📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cachito.env is referenced from https://github.com/openshift/networking-console-plugin/blob/release-4.20/Dockerfile.art#L23 but I am not sure if its needed TBH. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the newer cachi2 system. My analysis suggests two approaches:Option 1: Remove cachito.env sourcing entirely (Recommended)
The cachito.env sourcing is likely unnecessary. You could simplify to: RUN if [ -d vendor ]; then export GOFLAGS="-mod=vendor"; fi; \
go build -o assisted-disconnected-ui .Option 2: Make it conditional (Safer if unsure) RUN if [ -f ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env ]; then \
source ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env; \
fi; \
if [ -d vendor ]; then export GOFLAGS="-mod=vendor"; fi; \
go build -o assisted-disconnected-ui .Given that you're using vendored dependencies and this is a simple Go binary build, I'd recommend Option 1 - just remove the cachito.env sourcing entirely. The networking-console-plugin reference might be from an older pattern that's no longer needed. What's your preference? 🐰 curious ears perk up, investigating the mystery of the potentially unnecessary env file ✏️ Learnings added
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| FROM registry.ci.openshift.org/ocp/ubi-micro:9 | ||||||||||||||||||||||||||||||||||||||
| COPY --from=ui-build /app/apps/assisted-disconnected-ui/build /app/proxy/dist | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.