Dockerfile-front-backend 780 B

1234567891011121314151617181920212223242526272829303132
  1. # build front-end
  2. FROM node:lts-alpine AS frontend
  3. RUN npm install pnpm -g
  4. WORKDIR /app
  5. COPY ./package.json /app
  6. COPY ./pnpm-lock.yaml /app
  7. RUN pnpm install
  8. COPY . /app
  9. RUN pnpm run build
  10. # build backend
  11. FROM node:lts-alpine as backend
  12. RUN npm install pnpm -g
  13. WORKDIR /app
  14. COPY /service/package.json /app
  15. COPY /service/pnpm-lock.yaml /app
  16. RUN pnpm install
  17. COPY /service /app
  18. RUN pnpm build
  19. # service
  20. FROM node:lts-alpine as runner
  21. RUN npm install pnpm -g
  22. WORKDIR /app
  23. COPY /service/package.json /app
  24. COPY /service/pnpm-lock.yaml /app
  25. RUN pnpm install --production && rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
  26. COPY /service /app
  27. COPY --from=frontend /app/dist /app/public
  28. COPY --from=backend /app/build /app/build
  29. EXPOSE 3002
  30. CMD ["pnpm", "run", "prod"]