2024-04-02 15:52:39 -07:00
|
|
|
FROM node:20-alpine AS base
|
|
|
|
|
2024-05-26 13:58:53 -07:00
|
|
|
# to be able to read git hash
|
|
|
|
RUN apk -U upgrade && apk add --no-cache git openssh
|
|
|
|
RUN git config --global --add safe.directory /home/node/app
|
|
|
|
|
2024-04-02 22:55:30 -07:00
|
|
|
FROM base as dev_dep
|
|
|
|
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
|
|
|
WORKDIR /home/node/app
|
|
|
|
|
|
|
|
# --- dependencies ---
|
|
|
|
COPY --chown=node:node package*.json ./
|
|
|
|
COPY --chown=node:node packages/admin/package*.json ./packages/admin/
|
|
|
|
COPY --chown=node:node packages/client/package*.json ./packages/client/
|
|
|
|
COPY --chown=node:node packages/lib/package*.json ./packages/lib/
|
|
|
|
COPY --chown=node:node packages/server/package*.json ./packages/server/
|
|
|
|
|
|
|
|
USER node
|
|
|
|
RUN npm install --include=dev
|
|
|
|
|
|
|
|
FROM base as dep
|
|
|
|
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
|
|
|
WORKDIR /home/node/app
|
|
|
|
|
|
|
|
# --- dependencies ---
|
|
|
|
COPY --chown=node:node package*.json ./
|
|
|
|
COPY --chown=node:node packages/admin/package*.json ./packages/admin/
|
|
|
|
COPY --chown=node:node packages/client/package*.json ./packages/client/
|
|
|
|
COPY --chown=node:node packages/lib/package*.json ./packages/lib/
|
|
|
|
COPY --chown=node:node packages/server/package*.json ./packages/server/
|
|
|
|
|
|
|
|
USER node
|
|
|
|
RUN npm install --omit=dev
|
|
|
|
|
2024-04-02 15:52:39 -07:00
|
|
|
#
|
|
|
|
# === BUILDER ===
|
|
|
|
#
|
|
|
|
|
|
|
|
FROM base as build
|
|
|
|
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
|
|
|
|
WORKDIR /home/node/app
|
|
|
|
|
2024-05-26 13:58:53 -07:00
|
|
|
COPY --from=dev_dep --chown=node:node /home/node/app/ ./
|
2024-04-02 22:55:30 -07:00
|
|
|
COPY --chown=node:node . .
|
2024-04-02 15:52:39 -07:00
|
|
|
|
|
|
|
# --- build lib ---
|
|
|
|
|
|
|
|
RUN npm -w packages/lib run build
|
|
|
|
# janky? fix to keep imports in dev
|
|
|
|
RUN sed -i -e 's/"main": ".*"/"main": ".\/dist\/index.js"/' packages/lib/package.json
|
|
|
|
|
|
|
|
# --- build main client ---
|
|
|
|
|
2024-07-05 22:06:26 -07:00
|
|
|
ARG VITE_INCLUDE_EVENT_INFO
|
2024-04-02 15:52:39 -07:00
|
|
|
RUN npm -w packages/client run build
|
|
|
|
|
|
|
|
# --- build admin ---
|
|
|
|
|
2024-05-28 20:02:00 -07:00
|
|
|
ENV APP_ROOT /admin
|
2024-04-02 15:52:39 -07:00
|
|
|
RUN npm -w packages/admin run build
|
|
|
|
|
|
|
|
# --- build server ---
|
|
|
|
|
|
|
|
RUN npx -w packages/server prisma generate
|
|
|
|
RUN npm -w packages/server run build
|
|
|
|
|
|
|
|
#
|
|
|
|
# === RUNNER ===
|
|
|
|
#
|
|
|
|
|
|
|
|
FROM base as run
|
|
|
|
WORKDIR /home/node/app
|
2024-04-02 22:55:30 -07:00
|
|
|
COPY --from=dep /home/node/app/ ./
|
2024-06-26 17:38:46 -07:00
|
|
|
COPY package*.json docker-start*.sh .git ./
|
2024-04-02 15:52:39 -07:00
|
|
|
|
|
|
|
# --- prepare lib ---
|
|
|
|
|
|
|
|
RUN mkdir -p packages/lib
|
|
|
|
COPY --from=build /home/node/app/packages/lib/package.json ./packages/lib
|
|
|
|
COPY --from=build /home/node/app/packages/lib/dist ./packages/lib/dist
|
|
|
|
|
|
|
|
# --- prepare client ---
|
|
|
|
|
|
|
|
RUN mkdir -p packages/client
|
|
|
|
COPY --from=build /home/node/app/packages/client/dist ./packages/client/
|
|
|
|
|
|
|
|
# --- prepare admin ---
|
|
|
|
|
|
|
|
RUN mkdir -p packages/admin
|
|
|
|
COPY --from=build /home/node/app/packages/admin/dist ./packages/admin/
|
|
|
|
|
|
|
|
# --- prepare server ---
|
|
|
|
|
|
|
|
RUN mkdir -p packages/server
|
|
|
|
COPY --from=build /home/node/app/packages/server/package.json ./packages/server/
|
|
|
|
COPY --from=build /home/node/app/packages/server/prisma ./packages/server/prisma
|
|
|
|
COPY --from=build /home/node/app/packages/server/tool.sh ./packages/server/
|
|
|
|
COPY --from=build /home/node/app/packages/server/dist ./packages/server/dist
|
|
|
|
|
|
|
|
# --- finalize ---
|
|
|
|
|
|
|
|
RUN npx -w packages/server prisma generate
|
|
|
|
|
|
|
|
# set runtime env variables
|
|
|
|
|
|
|
|
ENV PORT 3000
|
|
|
|
ENV NODE_ENV production
|
|
|
|
ENV SERVE_CLIENT /home/node/app/packages/client
|
|
|
|
ENV SERVE_ADMIN /home/node/app/packages/admin
|
|
|
|
|
|
|
|
EXPOSE 3000
|
2024-07-10 09:16:54 -07:00
|
|
|
# profiler port, only used if profiler is explicity running
|
|
|
|
EXPOSE 9229
|
2024-04-02 15:52:39 -07:00
|
|
|
ENTRYPOINT [ "/bin/sh" ]
|
|
|
|
CMD [ "./docker-start.sh" ]
|