-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return back to alpine node base image
This commit resolves the EACCES issues we were previously encountering in and allows us to return to using alpine as our base container image. This will allow us to have more direct control over the version of node running. Signed-off-by: Jeremy Ho <[email protected]>
- Loading branch information
Showing
1 changed file
with
23 additions
and
31 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,51 +1,43 @@ | ||
# 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/ubi9/nodejs-18-minimal/62e8e919d4f57d92a9dee838 | ||
|
||
# | ||
# Build the application | ||
# | ||
FROM registry.access.redhat.com/ubi9/nodejs-18:1-70.1695740477 as application | ||
|
||
ENV NO_UPDATE_NOTIFIER=true | ||
|
||
USER 0 | ||
COPY app /tmp/src/app | ||
WORKDIR /tmp/src/app | ||
RUN chown -R 1001:0 /tmp/src/app | ||
|
||
USER 1001 | ||
RUN npm ci --omit=dev | ||
ARG APP_ROOT=/opt/app-root/src | ||
ARG BASE_IMAGE=docker.io/node:18.18.2-alpine | ||
|
||
# | ||
# Build the frontend | ||
# | ||
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-74.1695740475 as frontend | ||
FROM ${BASE_IMAGE} as frontend | ||
|
||
ARG APP_ROOT | ||
ENV NO_UPDATE_NOTIFIER=true | ||
|
||
USER 0 | ||
COPY frontend /tmp/src/frontend | ||
WORKDIR /tmp/src/frontend | ||
RUN chown -R 1001:0 /tmp/src/frontend | ||
|
||
COPY 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-67 | ||
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/frontend/dist ${HOME}/dist | ||
COPY .git ${HOME}/.git | ||
WORKDIR ${HOME} | ||
COPY --from=frontend /tmp/src/frontend/dist ${APP_ROOT}/dist | ||
COPY .git ${APP_ROOT}/.git | ||
COPY app ${APP_ROOT} | ||
WORKDIR ${APP_ROOT} | ||
|
||
# NPM Permission Fix | ||
RUN mkdir -p /.npm | ||
RUN chown -R 1001:0 /.npm | ||
|
||
# Install Application | ||
RUN chown -R 1001:0 ${APP_ROOT} | ||
USER 1001 | ||
WORKDIR ${APP_ROOT}/app | ||
RUN npm ci --omit=dev | ||
|
||
EXPOSE ${APP_PORT} | ||
CMD ["npm", "run", "start"] |