Dockerfile.dev 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Common base image
  2. FROM node:22-alpine AS common_base
  3. ARG UID=1000
  4. ARG GID=1000
  5. RUN deluser --remove-home node \
  6. && addgroup -S -g ${GID} musare \
  7. && adduser -SD -u ${UID} musare \
  8. && adduser musare musare
  9. RUN mkdir -p /opt/.git /opt/types /opt/app \
  10. && chown -R musare:musare /opt/app
  11. WORKDIR /opt/app
  12. USER musare
  13. # Server node modules
  14. FROM common_base AS server_node_modules
  15. COPY --chown=musare:musare --link server/package.json server/package-lock.json /opt/app/
  16. RUN npm install
  17. # Server development image
  18. FROM common_base AS server
  19. ENV APP_ENV=development
  20. COPY --chown=musare:musare --link .git /opt/.git
  21. COPY --chown=musare:musare --link server /opt/app
  22. COPY --chown=musare:musare --link --from=server_node_modules /opt/app/node_modules node_modules
  23. ENTRYPOINT sh /opt/app/entrypoint.dev.sh
  24. EXPOSE 3030
  25. # Backend node modules
  26. FROM common_base AS backend_node_modules
  27. COPY --chown=musare:musare --link backend/package.json backend/package-lock.json /opt/app/
  28. RUN npm install
  29. # Backend development image
  30. FROM common_base AS backend
  31. ENV APP_ENV=development
  32. COPY --chown=musare:musare --link .git /opt/.git
  33. COPY --chown=musare:musare --link backend /opt/app
  34. COPY --chown=musare:musare --link --from=backend_node_modules /opt/app/node_modules node_modules
  35. ENTRYPOINT sh /opt/app/entrypoint.dev.sh
  36. EXPOSE 8080
  37. # Frontend node modules
  38. FROM common_base AS frontend_node_modules
  39. COPY --chown=musare:musare --link frontend/package.json frontend/package-lock.json /opt/app/
  40. RUN npm install
  41. # Frontend development image
  42. FROM common_base AS frontend
  43. ARG MUSARE_SITENAME=Musare
  44. ARG MUSARE_PRIMARY_COLOR="#03a9f4"
  45. ARG MUSARE_DEBUG_VERSION=true
  46. ARG MUSARE_DEBUG_GIT_REMOTE=false
  47. ARG MUSARE_DEBUG_GIT_REMOTE_URL=false
  48. ARG MUSARE_DEBUG_GIT_BRANCH=true
  49. ARG MUSARE_DEBUG_GIT_LATEST_COMMIT=true
  50. ARG MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT=true
  51. ENV APP_ENV=development \
  52. MUSARE_SITENAME=${MUSARE_SITENAME} \
  53. MUSARE_PRIMARY_COLOR=${MUSARE_PRIMARY_COLOR} \
  54. MUSARE_DEBUG_VERSION=${MUSARE_DEBUG_VERSION} \
  55. MUSARE_DEBUG_GIT_REMOTE=${MUSARE_DEBUG_GIT_REMOTE} \
  56. MUSARE_DEBUG_GIT_REMOTE_URL=${MUSARE_DEBUG_GIT_REMOTE_URL} \
  57. MUSARE_DEBUG_GIT_BRANCH=${MUSARE_DEBUG_GIT_BRANCH} \
  58. MUSARE_DEBUG_GIT_LATEST_COMMIT=${MUSARE_DEBUG_GIT_LATEST_COMMIT} \
  59. MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT=${MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT}
  60. USER root
  61. RUN apk update \
  62. && apk add nginx \
  63. && sed -i 's/user nginx;/user musare;/' /etc/nginx/nginx.conf \
  64. && chown -R musare:musare /etc/nginx/http.d /run/nginx /var/lib/nginx /var/log/nginx
  65. USER musare
  66. COPY --chown=musare:musare --link .git /opt/.git
  67. COPY --chown=musare:musare --link types /opt/types
  68. COPY --chown=musare:musare --link frontend /opt/app
  69. COPY --chown=musare:musare --from=frontend_node_modules --link /opt/app/node_modules node_modules
  70. ENTRYPOINT sh /opt/app/entrypoint.dev.sh
  71. EXPOSE 80