Dockerfile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # Based of https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
  2. ARG VARIANT=24-bookworm
  3. FROM node:${VARIANT}
  4. ARG USERNAME=node
  5. ARG NPM_GLOBAL=/usr/local/share/npm-global
  6. ENV DEBIAN_FRONTEND=noninteractive
  7. # Add NPM global to PATH.
  8. ENV PATH=${NPM_GLOBAL}/bin:${PATH}
  9. RUN \
  10. # Configure global npm install location, use group to adapt to UID/GID changes
  11. if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
  12. && usermod -a -G npm ${USERNAME} \
  13. && umask 0002 \
  14. && mkdir -p ${NPM_GLOBAL} \
  15. && touch /usr/local/etc/npmrc \
  16. && chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
  17. && chmod g+s ${NPM_GLOBAL} \
  18. && npm config -g set prefix ${NPM_GLOBAL} \
  19. && su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
  20. # Install eslint
  21. && su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
  22. && npm cache clean --force > /dev/null 2>&1
  23. # Enable PNPM
  24. ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
  25. RUN corepack enable \
  26. && corepack prepare pnpm@latest --activate
  27. EXPOSE 3000
  28. # Install the packages we need
  29. RUN apt-get update && apt-get install -qy \
  30. bash \
  31. build-essential \
  32. curl \
  33. jq \
  34. less \
  35. git \
  36. gnupg2 \
  37. nano \
  38. netcat-openbsd \
  39. pandoc \
  40. unzip \
  41. wget
  42. # avoid million NPM install messages
  43. ENV npm_config_loglevel=warn
  44. # allow installing when the main user is root
  45. ENV npm_config_unsafe_perm=true
  46. # disable NPM funding messages
  47. ENV npm_config_fund=false
  48. # Colorize the bash shell
  49. RUN sed -i 's/#force_color_prompt=/force_color_prompt=/' /root/.bashrc
  50. # Copy wait-for utility
  51. COPY wait-for.sh /usr/local/bin/wait-for
  52. RUN chmod +rx /usr/local/bin/wait-for
  53. # Copy the startup file
  54. COPY app-init.sh /docker-init.sh
  55. RUN sed -i 's/\r$//' /docker-init.sh && \
  56. chmod +x /docker-init.sh
  57. # Create workspace
  58. RUN mkdir -p /workspace
  59. WORKDIR /workspace
  60. ENV NODE_ENV=development