diff --git a/apps/assisted-disconnected-ui/Containerfile.ocp b/apps/assisted-disconnected-ui/Containerfile.ocp index 34a4503ef3..9e754b01ab 100644 --- a/apps/assisted-disconnected-ui/Containerfile.ocp +++ b/apps/assisted-disconnected-ui/Containerfile.ocp @@ -1,21 +1,62 @@ +################################################## +# +# nodejs frontend build FROM registry.ci.openshift.org/ocp/builder:rhel-9-base-nodejs-openshift-4.19 AS ui-build -USER root + +USER 0 + +ARG YARN_VERSION=v3.4.1 + +# bootstrap yarn so we can install and run the other tools. +RUN CACHED_YARN=./artifacts/yarn-${YARN_VERSION}.tar.gz; \ + if [ -f ${CACHED_YARN} ]; then \ + npm install -g ${CACHED_YARN}; \ + else \ + npm install https://github.com/yarnpkg/yarn/releases/download/${YARN_VERSION}/yarn-${YARN_VERSION}.tar.gz; \ + exit 1; \ + fi + +# 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=apps/assisted-disconnected-ui/Containerfile.ocp +ARG REMOTE_SOURCES_DIR=/remote-sources + +COPY $REMOTE_SOURCES $REMOTE_SOURCES_DIR 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 -RUN yarn install --immutable && yarn build:all +# 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/{.yarnrc.yml,yarn.lock,.package.json,apps/assisted-disconnected-ui/package.json} . \ + && . ${REMOTE_SOURCES_DIR}/cachito-gomod-with-deps/cachito.env \ + && yarn install --immutable && yarn build:all + +################################################## +# +# go backend build 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 if [ -d vendor ]; then export GOFLAGS="-mod=vendor"; fi; \ + go build -o assisted-disconnected-ui . -FROM registry.ci.openshift.org/ocp/ubi-micro:9 +################################################## +# +# actual base image for final product +FROM registry.ci.openshift.org/ocp/4.20:base-rhel9 COPY --from=ui-build /app/apps/assisted-disconnected-ui/build /app/proxy/dist COPY --from=proxy-build /app/assisted-disconnected-ui /app/proxy WORKDIR /app/proxy