Dockerfile.dev 2.5 KB

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