Bird
0
0

You want to optimize your Remix Dockerfile to cache dependencies and speed up rebuilds. Which Dockerfile order is best?

hard📝 Application Q15 of 15
Remix - Deployment
You want to optimize your Remix Dockerfile to cache dependencies and speed up rebuilds. Which Dockerfile order is best?
ACOPY package.json .\nRUN npm install\nCOPY . .\nCMD ["npm", "run", "start"]
BCOPY . .\nRUN npm install\nCMD ["npm", "run", "start"]
CRUN npm install\nCOPY . .\nCMD ["npm", "run", "start"]
DCMD ["npm", "run", "start"]\nCOPY package.json .\nRUN npm install
Step-by-Step Solution
Solution:
  1. Step 1: Understand Docker layer caching

    Docker caches layers; copying package.json and running npm install first caches dependencies.
  2. Step 2: Analyze COPY package.json .\nRUN npm install\nCOPY . .\nCMD ["npm", "run", "start"] order

    COPY package.json .\nRUN npm install\nCOPY . .\nCMD ["npm", "run", "start"] copies package.json, installs dependencies, then copies rest of files, so changes to app code don't rerun npm install.
  3. Final Answer:

    COPY package.json .\nRUN npm install\nCOPY . .\nCMD ["npm", "run", "start"] -> Option A
  4. Quick Check:

    Cache dependencies by copying package.json first = B [OK]
Quick Trick: Copy package.json and run npm install before app files [OK]
Common Mistakes:
MISTAKES
  • Copying all files before npm install
  • Running npm install before copying package.json
  • Placing CMD before install steps

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes