notebrook-notes/dockerfile

37 lines
1.2 KiB
Plaintext
Raw Normal View History

FROM node:22-slim AS base
2024-08-23 14:45:28 +00:00
WORKDIR /usr/src/app
FROM base AS install
2024-08-26 09:20:12 +00:00
COPY backend/package.json backend/package-lock.json /temp/dev/backend/
COPY frontend/package.json frontend/package-lock.json /temp/dev/frontend/
2024-08-23 14:45:28 +00:00
2024-08-26 09:20:12 +00:00
RUN cd /temp/dev/backend && npm install
RUN cd /temp/dev/frontend && npm install
2024-08-23 14:45:28 +00:00
RUN mkdir -p /temp/prod/backend /temp/prod/frontend
2024-08-26 09:20:12 +00:00
COPY backend/package.json backend/package-lock.json /temp/prod/backend/
COPY frontend/package.json frontend/package-lock.json /temp/prod/frontend/
2024-08-23 14:45:28 +00:00
2024-08-26 09:20:12 +00:00
RUN cd /temp/prod/backend && npm install --production
RUN cd /temp/prod/frontend && npm install --production
2024-08-23 14:45:28 +00:00
FROM install AS build-frontend
WORKDIR /usr/src/app/frontend
COPY frontend/ .
COPY --from=install /temp/dev/frontend/node_modules node_modules
2024-08-26 09:20:12 +00:00
RUN npm run build
2024-08-23 14:45:28 +00:00
FROM base AS release
WORKDIR /usr/src/app
COPY backend/ backend/
2024-08-23 14:45:28 +00:00
COPY --from=install /temp/prod/backend/node_modules backend/node_modules
COPY --from=install /temp/prod/frontend/node_modules frontend/node_modules
COPY --from=build-frontend /usr/src/app/frontend/dist backend/public
2024-08-26 09:20:12 +00:00
USER node
WORKDIR /usr/src/app/backend
2024-08-23 14:45:28 +00:00
EXPOSE 3000/tcp
2024-08-26 09:20:12 +00:00
ENTRYPOINT [ "npm", "run", "start"]