Dockerfile 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. for i in 1 2 3; do \
  22. npm ci && break || \
  23. if [ $i -lt 3 ]; then \
  24. sleep 15; \
  25. else \
  26. exit 1; \
  27. fi; \
  28. done
  29. # Run the build command if necessary
  30. RUN cd src/gui && npm run build && cd -
  31. # Production stage
  32. FROM node:21-alpine
  33. # Set labels
  34. LABEL repo="https://github.com/HeyPuter/puter"
  35. LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
  36. LABEL version="1.2.46-beta-1"
  37. # Install git (required by Puter to check version)
  38. RUN apk add --no-cache git
  39. # Set up working directory
  40. RUN mkdir -p /opt/puter/app
  41. WORKDIR /opt/puter/app
  42. # Copy built artifacts and necessary files from the build stage
  43. COPY --from=build /app/src/gui/dist ./dist
  44. COPY --from=build /app/node_modules ./node_modules
  45. COPY . .
  46. # Set permissions
  47. RUN chown -R node:node /opt/puter/app
  48. USER node
  49. EXPOSE 4100
  50. HEALTHCHECK --interval=30s --timeout=3s \
  51. CMD wget --no-verbose --tries=1 --spider http://puter.localhost:4100/test || exit 1
  52. ENV NO_VAR_RUNTUME=1
  53. CMD ["npm", "start"]