Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create explicit docker stage for app build #13

Merged
merged 1 commit into from
Dec 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]