Dockerfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Specify the base Docker image. You can read more about
  2. # the available images at https://crawlee.dev/docs/guides/docker-images
  3. # You can also use any other image from Docker Hub.
  4. FROM apify/actor-node-playwright-chrome:18 AS builder
  5. # Copy just package.json and package-lock.json
  6. # to speed up the build using Docker layer cache.
  7. COPY --chown=myuser package*.json ./
  8. # Install all dependencies. Don't audit to speed up the installation.
  9. RUN npm install --include=dev --audit=false
  10. # Next, copy the source files using the user set
  11. # in the base image.
  12. COPY --chown=myuser . ./
  13. # Install all dependencies and build the project.
  14. # Don't audit to speed up the installation.
  15. RUN npm run build
  16. # Create final image
  17. FROM apify/actor-node-playwright-chrome:18
  18. # Copy only built JS files from builder image
  19. COPY --from=builder --chown=myuser /home/myuser/dist ./dist
  20. # Copy just package.json and package-lock.json
  21. # to speed up the build using Docker layer cache.
  22. COPY --chown=myuser package*.json ./
  23. # Install NPM packages, skip optional and development dependencies to
  24. # keep the image small. Avoid logging too much and print the dependency
  25. # tree for debugging
  26. RUN npm --quiet set progress=false \
  27. && npm install --omit=dev --omit=optional \
  28. && echo "Installed NPM packages:" \
  29. && (npm list --omit=dev --all || true) \
  30. && echo "Node.js version:" \
  31. && node --version \
  32. && echo "NPM version:" \
  33. && npm --version
  34. # Next, copy the remaining files and directories with the source code.
  35. # Since we do this after NPM install, quick build will be really fast
  36. # for most source file changes.
  37. COPY --chown=myuser . ./
  38. # Run the image. If you know you won't need headful browsers,
  39. # you can remove the XVFB start script for a micro perf gain.
  40. CMD ./start_xvfb_and_run_cmd.sh && npm run start:prod --silent