Dockerfile.dev 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # Backend node modules
  14. FROM common_base AS backend_node_modules
  15. COPY --chown=musare:musare --link backend/package.json backend/package-lock.json /opt/app/
  16. RUN npm install
  17. # Backend development image
  18. FROM common_base AS backend
  19. ENV APP_ENV=development
  20. COPY --chown=musare:musare --link .git /opt/.git
  21. COPY --chown=musare:musare --link backend /opt/app
  22. COPY --chown=musare:musare --link --from=backend_node_modules /opt/app/node_modules node_modules
  23. ENTRYPOINT sh /opt/app/entrypoint.dev.sh
  24. EXPOSE 8080
  25. # Frontend node modules
  26. FROM common_base AS frontend_node_modules
  27. COPY --chown=musare:musare --link frontend/package.json frontend/package-lock.json /opt/app/
  28. RUN npm install
  29. # Frontend development image
  30. FROM common_base AS frontend
  31. ARG MUSARE_SITENAME=Musare
  32. ARG MUSARE_PRIMARY_COLOR="#03a9f4"
  33. ARG MUSARE_DEBUG_VERSION=true
  34. ARG MUSARE_DEBUG_GIT_REMOTE=false
  35. ARG MUSARE_DEBUG_GIT_REMOTE_URL=false
  36. ARG MUSARE_DEBUG_GIT_BRANCH=true
  37. ARG MUSARE_DEBUG_GIT_LATEST_COMMIT=true
  38. ARG MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT=true
  39. ENV APP_ENV=development \
  40. MUSARE_SITENAME=${MUSARE_SITENAME} \
  41. MUSARE_PRIMARY_COLOR=${MUSARE_PRIMARY_COLOR} \
  42. MUSARE_DEBUG_VERSION=${MUSARE_DEBUG_VERSION} \
  43. MUSARE_DEBUG_GIT_REMOTE=${MUSARE_DEBUG_GIT_REMOTE} \
  44. MUSARE_DEBUG_GIT_REMOTE_URL=${MUSARE_DEBUG_GIT_REMOTE_URL} \
  45. MUSARE_DEBUG_GIT_BRANCH=${MUSARE_DEBUG_GIT_BRANCH} \
  46. MUSARE_DEBUG_GIT_LATEST_COMMIT=${MUSARE_DEBUG_GIT_LATEST_COMMIT} \
  47. MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT=${MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT}
  48. USER root
  49. RUN apk update \
  50. && apk add nginx \
  51. && sed -i 's/user nginx;/user musare;/' /etc/nginx/nginx.conf \
  52. && chown -R musare:musare /etc/nginx/http.d /run/nginx /var/lib/nginx /var/log/nginx
  53. USER musare
  54. COPY --chown=musare:musare --link .git /opt/.git
  55. COPY --chown=musare:musare --link types /opt/types
  56. COPY --chown=musare:musare --link frontend /opt/app
  57. COPY --chown=musare:musare --from=frontend_node_modules --link /opt/app/node_modules node_modules
  58. ENTRYPOINT sh /opt/app/entrypoint.dev.sh
  59. EXPOSE 80