Dockerfile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # /!\ NOTICE /!\
  2. # Many of the developers DO NOT USE the Dockerfile or image.
  3. # While we do test new changes to Docker configuration, it's
  4. # possible that future changes to the repo might break it.
  5. # When changing this file, please try to make it as resiliant
  6. # to such changes as possible; developers shouldn't need to
  7. # worry about Docker unless the build/run process changes.
  8. # Build stage
  9. FROM node:21-alpine AS build
  10. # Install build dependencies
  11. RUN apk add --no-cache git python3 make g++ \
  12. && ln -sf /usr/bin/python3 /usr/bin/python
  13. # Set up working directory
  14. WORKDIR /app
  15. # Copy package.json and package-lock.json
  16. COPY package*.json ./
  17. # Copy the source files
  18. COPY . .
  19. # Install node modules
  20. RUN npm cache clean --force \
  21. && npm ci
  22. # Run the build command if necessary
  23. RUN npm run build
  24. # Production stage
  25. FROM node:21-alpine
  26. # Set labels
  27. LABEL repo="https://github.com/HeyPuter/puter"
  28. LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
  29. LABEL version="1.2.46-beta-1"
  30. # Install git (required by Puter to check version)
  31. RUN apk add --no-cache git
  32. # Set up working directory
  33. RUN mkdir -p /opt/puter/app
  34. WORKDIR /opt/puter/app
  35. # Copy built artifacts and necessary files from the build stage
  36. COPY --from=build /app/dist ./dist
  37. COPY --from=build /app/node_modules ./node_modules
  38. COPY . .
  39. # Set permissions
  40. RUN chown -R node:node /opt/puter/app
  41. USER node
  42. EXPOSE 4100
  43. HEALTHCHECK --interval=30s --timeout=3s \
  44. CMD wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test || exit 1
  45. ENV NO_VAR_RUNTUME=1
  46. CMD ["npm", "start"]