🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
HTML MASTER CLASS /// LEARN TAGS /// BUILD STRUCTURE /// SEMANTIC WEB /// HTML MASTER CLASS /// LEARN TAGS ///

Untitled Lesson

Total XP: 0|💻 backend XP: 0

Skill Matrix

UNLOCK NODES BY LEARNING NEW TAGS.

Select an unlocked node to view details root

Pascual Vila

Pascual Vila

Frontend Instructor // Code Syllabus

Common Pitfalls & Errors

The Error //

Copying a local node_modules folder into a Linux container

# .dockerignore node_modules # Dockerfile COPY package*.json ./ RUN npm ci --omit=dev COPY . .

The Solution //

Native modules with C++ bindings (bcrypt, sharp, node-sass, etc.) are compiled for the host OS/architecture. A node_modules folder built on macOS/Windows contains binaries the Linux container can't execute, causing 'invalid ELF header' crashes. Add node_modules to .dockerignore and always run npm install/npm ci inside the Dockerfile so modules are compiled for the container's own platform.

The Error //

Forgetting to ignore .env, baking secrets into the image layer

# .dockerignore .env .env.* # Anyone with the image can still extract a baked-in secret: # docker history --no-trunc <image> | grep API_KEY

The Solution //

COPY . . without a .dockerignore entry for .env permanently embeds database passwords and API keys into an image layer — even if a later layer deletes the file, it's still recoverable from the image history. Add .env and .env.* to .dockerignore and inject secrets at runtime instead (env_file in Compose, Kubernetes secrets, or your platform's secret manager).

Continue Learning