Dockerfile 588 B

123456789101112131415161718192021222324252627282930
  1. FROM node:20-bookworm
  2. RUN apt-get update && apt-get install -y \
  3. git \
  4. curl \
  5. && rm -rf /var/lib/apt/lists/*
  6. # Set up non-root user
  7. ARG USERNAME=node
  8. ARG USER_UID=1000
  9. ARG USER_GID=$USER_UID
  10. # Create the user if it doesn't exist
  11. RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
  12. groupmod --gid $USER_GID $USERNAME \
  13. && usermod --uid $USER_UID --gid $USER_GID $USERNAME; \
  14. fi
  15. # Set up workspace
  16. WORKDIR /workspace
  17. RUN chown $USERNAME:$USERNAME /workspace
  18. COPY package*.json ./
  19. RUN npm install
  20. COPY . .
  21. EXPOSE 3000
  22. USER $USERNAME