Dockerfile.dev 2.5 KB

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