Building Openshift Images on a Mac - zhuje/openshift-wiki GitHub Wiki
Notes on Building Images on a Mac
https://docs.google.com/document/d/1KAibZZ4M4OtJ9Wgb-PJWcdmXLGiRzpVUxEss7dYZlxE/edit
Instructions
- In .dockerignore > remove
web/dist
- In Dockerfile.local (or whatever Dockerfile you're using to build) - don't build
npm/yarn install
because it hangs on a Mac. You need to build thedist
files locally -- this is all contains all the javascript files you'll need to run your application -- the executable files (these are agnostic to your platform so we can build them on our local machine then copy them into the image).
- comment out
RUN npm install --global yarn
- comment out
RUN make install-frontend
- comment out
RUN make build-frontend
- the dist files in this case are in
web
soCOPY web/ web/
will copy the executable web/dist into our image
# openshift/monitoring-plugin > Dockerfile.local
FROM registry.redhat.io/ubi9/nodejs-20-minimal:1-51 AS web-builder
WORKDIR /opt/app-root
# RUN npm install --global yarn
ENV HUSKY=0
COPY Makefile Makefile
COPY web/ web/
# RUN make install-frontend
# RUN make build-frontend
# Almost all images from Red Hat are still on go1.21, however I found one that the cne team has
# created. Once official Red Hat images are available for local development and pulling this
# should be updated
FROM quay.io/redhat-cne/openshift-origin-release:rhel-9-golang-1.22-openshift-4.17 as go-builder
WORKDIR /opt/app-root
COPY Makefile Makefile
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
COPY cmd/ cmd/
COPY pkg/ pkg/
RUN go build -mod=mod -o plugin-backend cmd/plugin-backend.go
FROM registry.access.redhat.com/ubi9/ubi-minimal
RUN microdnf install nginx findutils && \
mkdir /var/cache/nginx && \
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run
USER 1001
COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist
COPY --from=go-builder /opt/app-root/plugin-backend /opt/app-root
COPY --from=web-builder /opt/app-root/web/dist /usr/share/nginx/html
ENTRYPOINT ["nginx", "-g", "daemon off;"]
# When nginx is removed from CMO, we can use the following ENTRYPOINT instead
# After it has been removed add the CI checks to this repo. [example](https://github.com/openshift/release/pull/56011)
# ENTRYPOINT ["/opt/app-root/plugin-backend", "-static-path", "/opt/app-root/web/dist"]