Dockerfile 1.8 KB

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