Dockerfile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. FROM node:20-alpine AS frontend_base
  2. ARG UID=1000
  3. ARG GID=1000
  4. RUN deluser --remove-home node \
  5. && addgroup -S -g ${GID} musare \
  6. && adduser -SD -u ${UID} musare \
  7. && adduser musare musare
  8. RUN mkdir -p /opt/.git /opt/common /opt/types /opt/app /run/nginx \
  9. && chown -R musare:musare /opt/app
  10. WORKDIR /opt/app
  11. USER musare
  12. FROM frontend_base AS frontend_node_modules
  13. COPY --chown=musare:musare --link frontend/package.json frontend/package-lock.json /opt/app/
  14. RUN npm install
  15. FROM frontend_base AS musare_frontend
  16. ARG FRONTEND_MODE=production
  17. ARG FRONTEND_PROD_DEVTOOLS=false
  18. ARG MUSARE_SITENAME=Musare
  19. ARG MUSARE_PRIMARY_COLOR="#03a9f4"
  20. ARG MUSARE_DEBUG_VERSION=true
  21. ARG MUSARE_DEBUG_GIT_REMOTE=false
  22. ARG MUSARE_DEBUG_GIT_REMOTE_URL=false
  23. ARG MUSARE_DEBUG_GIT_BRANCH=true
  24. ARG MUSARE_DEBUG_GIT_LATEST_COMMIT=true
  25. ARG MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT=true
  26. ENV FRONTEND_MODE=${FRONTEND_MODE} \
  27. FRONTEND_PROD_DEVTOOLS=${FRONTEND_PROD_DEVTOOLS} \
  28. MUSARE_SITENAME=${MUSARE_SITENAME} \
  29. MUSARE_PRIMARY_COLOR=${MUSARE_PRIMARY_COLOR} \
  30. MUSARE_DEBUG_VERSION=${MUSARE_DEBUG_VERSION} \
  31. MUSARE_DEBUG_GIT_REMOTE=${MUSARE_DEBUG_GIT_REMOTE} \
  32. MUSARE_DEBUG_GIT_REMOTE_URL=${MUSARE_DEBUG_GIT_REMOTE_URL} \
  33. MUSARE_DEBUG_GIT_BRANCH=${MUSARE_DEBUG_GIT_BRANCH} \
  34. MUSARE_DEBUG_GIT_LATEST_COMMIT=${MUSARE_DEBUG_GIT_LATEST_COMMIT} \
  35. MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT=${MUSARE_DEBUG_GIT_LATEST_COMMIT_SHORT}
  36. USER root
  37. RUN apk add nginx
  38. USER musare
  39. COPY --chown=musare:musare --link .git /opt/.git
  40. COPY --chown=musare:musare --link common /opt/common
  41. COPY --chown=musare:musare --link types /opt/types
  42. COPY --chown=musare:musare --link frontend /opt/app
  43. COPY --chown=musare:musare --from=frontend_node_modules --link /opt/app/node_modules node_modules
  44. RUN sh -c '([[ "${FRONTEND_MODE}" == "development" ]] && exit 0) || npm run prod'
  45. RUN chmod u+x entrypoint.sh
  46. ENTRYPOINT sh /opt/app/entrypoint.sh
  47. EXPOSE 80/tcp