-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework dockerfile with new base image
- Loading branch information
1 parent
804d62e
commit b4d1f21
Showing
1 changed file
with
35 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,62 @@ | ||
# FROM docker.io/node:16.15.0-alpine # Last known working alpine image | ||
|
||
# RedHat Image Catalog references | ||
# https://catalog.redhat.com/software/containers/ubi9/nodejs-18/62e8e7ed22d1d3c2dfe2ca01 | ||
# https://catalog.redhat.com/software/containers/ubi8/nodejs-16/615aee9fc739c0a4123a87e1 | ||
# https://catalog.redhat.com/software/containers/ubi9/nodejs-18-minimal/62e8e919d4f57d92a9dee838 | ||
ARG APP_ROOT=/opt/app-root/src | ||
ARG BASE_IMAGE=docker.io/node:20.11.1-alpine | ||
|
||
# | ||
# Build the application | ||
# Build the app | ||
# | ||
FROM registry.access.redhat.com/ubi9/nodejs-18:1-48 as application | ||
FROM ${BASE_IMAGE} as app | ||
|
||
ARG APP_ROOT | ||
ENV NO_UPDATE_NOTIFIER=true | ||
|
||
USER 0 | ||
COPY --chown=1001:0 app /tmp/src/app | ||
WORKDIR /tmp/src/app | ||
# NPM Permission Fix | ||
RUN mkdir -p /.npm | ||
RUN chown -R 1001:0 /.npm | ||
|
||
# Build App | ||
COPY app ${APP_ROOT} | ||
RUN chown -R 1001:0 ${APP_ROOT} | ||
USER 1001 | ||
WORKDIR ${APP_ROOT} | ||
RUN npm ci --omit=dev | ||
|
||
# | ||
# Build the frontend | ||
# | ||
FROM registry.access.redhat.com/ubi8/nodejs-16:1-105.1684740145 as frontend | ||
FROM ${BASE_IMAGE} as frontend | ||
|
||
ARG APP_ROOT | ||
ENV NO_UPDATE_NOTIFIER=true | ||
USER 0 | ||
COPY --chown=1001:0 app/frontend /tmp/src/app/frontend | ||
|
||
WORKDIR /tmp/src/app/frontend | ||
USER 1001 | ||
# NPM Permission Fix | ||
RUN mkdir -p /.npm | ||
RUN chown -R 1001:0 /.npm | ||
|
||
# Build Frontend | ||
COPY app/frontend ${APP_ROOT} | ||
RUN chown -R 1001:0 ${APP_ROOT} | ||
USER 1001 | ||
WORKDIR ${APP_ROOT} | ||
RUN npm ci && npm run build | ||
|
||
# | ||
# Create the final container image | ||
# | ||
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-51 | ||
FROM ${BASE_IMAGE} | ||
|
||
ARG APP_ROOT | ||
ENV APP_PORT=8080 \ | ||
NO_UPDATE_NOTIFIER=true | ||
|
||
COPY --from=application /tmp/src/app ${HOME} | ||
COPY --from=frontend /tmp/src/app/frontend/dist ${HOME}/frontend/dist | ||
COPY .git ${HOME}/.git | ||
WORKDIR ${HOME} | ||
# NPM Permission Fix | ||
RUN mkdir -p /.npm | ||
RUN chown -R 1001:0 /.npm | ||
|
||
# Install File Structure | ||
COPY --from=app ${APP_ROOT} ${APP_ROOT} | ||
COPY --from=frontend ${APP_ROOT}/dist ${APP_ROOT}/frontend/dist | ||
COPY .git ${APP_ROOT}/.git | ||
WORKDIR ${APP_ROOT} | ||
|
||
EXPOSE ${APP_PORT} | ||
CMD ["npm", "run", "start"] | ||
CMD ["node", "./bin/www"] |