Skip to content

Commit

Permalink
Create explicit docker stage for app build
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Ho <[email protected]>
  • Loading branch information
jujaga committed Dec 22, 2023
1 parent 2bec837 commit d70d008
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
ARG APP_ROOT=/opt/app-root/src
ARG BASE_IMAGE=docker.io/node:20.9.0-alpine

#
# Build the app
#
FROM ${BASE_IMAGE} as app

ARG APP_ROOT
ENV NO_UPDATE_NOTIFIER=true

# 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 && npm run build

#
# Build the frontend
#
Expand Down Expand Up @@ -34,15 +53,17 @@ RUN mkdir -p /.npm
RUN chown -R 1001:0 /.npm

# Install File Structure
COPY --from=app ${APP_ROOT}/sbin ${APP_ROOT}/sbin
COPY --from=frontend ${APP_ROOT}/dist ${APP_ROOT}/dist
COPY .git ${APP_ROOT}/.git
COPY app ${APP_ROOT}
COPY app/config ${APP_ROOT}/config
COPY app/package.json app/package-lock.json ${APP_ROOT}
WORKDIR ${APP_ROOT}

# Install Application
RUN chown -R 1001:0 ${APP_ROOT}
USER 1001
RUN npm ci --omit=dev && npm run build
RUN npm ci --omit=dev

EXPOSE ${APP_PORT}
CMD ["node", "./sbin/bin/www"]

0 comments on commit d70d008

Please sign in to comment.