Are you still using the same Dockerfile for development and production? Early in my career, I made this mistake constantly. One giant Dockerfile that installed dev dependencies, debugging tools, and everything else — then shipped it all to production. The image was bloated, slow to build, and a security risk. The fix? Multi-stage builds. They changed how I think about Docker entirely. Here's the pattern I use on almost every project now: # Stage 1: Build FROM composer:2 AS builder WORKDIR /app COPY composer.json composer.lock ./ RUN composer install --no-dev --optimize-autoloader COPY . . # Stage 2: Production FROM php:8.3-fpm-alpine COPY --from=builder /app /var/www/html RUN chown -R www-data:www-data /var/www/html/storage The key benefits I've seen after adopting this approach: - Final image dropped from ~800MB to ~120MB - Build cache works better because dependency install is separated from code copy - No dev tools or composer in the production image (smaller attack surface) - CI/CD pipelines got noticeably faster One extra tip: always use specific base image tags (php:8.3-fpm-alpine instead of php:latest). I learned this the hard way when a "latest" tag update broke a production deployment on a Friday evening. After 9+ years building and deploying applications, I can say that investing time in your Docker setup pays off every single day — faster builds, safer deployments, and fewer surprises at 2 AM. What's your go-to Docker optimization trick? I'd love to hear what's worked for your team. #Docker #DevOps #PHP #Laravel #Backend #WebDevelopment #CICD
Optimize Docker with Multi-Stage Builds and Specific Base Images
More Relevant Posts
-
I had to create 50 folders and 70 files for a project. I looked at the ASCII tree. Looked at my terminal. Thought "absolutely not" — and spent the next few days building a tool to do it for me instead. Classic developer move. No regrets. So I built: Folder Structure Visualizer Paste any ASCII folder tree → explore it like a real project → download a working scaffold in seconds. Not just empty folders. It generates real project starters: → React + Vite (JSX / TSX) → Tailwind CSS setup → Node + Express backend → Any combination, placed anywhere in your tree Run npm install → npm run dev → it just works. The hardest part? The parser. ASCII trees look simple… until you try to parse them. Different formats. Different spacing. Pipes, indents, mixed styles. The first version broke on anything that wasn't perfectly formatted. The fix: two separate parsers — ASCII-style + indentation-style — with automatic detection. Took a few "what is happening" moments to get right. What I learned building this: → Solve your own problem first. The best tools come from real frustration. → "Simple" inputs are never simple. Text is chaos. → Shipping something imperfect beats perfecting something unshipped. → The WTF moments are where the actual learning happens. Built with React + Vite, JSZip — and a lot of trial and error. If this saves you from manually creating folders — glad it helped. If it breaks — I'd love to hear about it 😄 P.S. Works on my machine — said every developer. #webdev #react #javascript #opensource #buildinpublic #devtools #sideproject
To view or add a comment, sign in
-
🚨 This bug cost us hours… and nobody could figure it out. UI looked fine. API response was correct. Logs were clean. But still… data was magically changing 🤯 After 12+ years in frontend development, I’ve seen this pattern again and again: 👉 The issue wasn’t React 👉 The issue wasn’t the API 👉 The issue was… JavaScript Objects & Arrays 💥 The real problem? A developer wrote something like this: const user = { name: "Parth" }; const copy = user; copy.name = "John"; Looks harmless, right? 👉 But suddenly: user.name === "John" 😳 Wait… WHAT? 🧠 This is where most developers go wrong: Objects & Arrays in JavaScript are REFERENCE types 👉 You’re not copying values 👉 You’re copying memory references So both variables point to the same data in memory 🔥 And this gets worse in real apps: ❌ React state updates behaving weird ❌ API data getting mutated unexpectedly ❌ Debugging takes HOURS ❌ Bugs that are hard to reproduce ⚠️ One more sneaky example: const obj = { nested: { count: 1 } }; const copy = { ...obj }; copy.nested.count = 99; 👉 You think it’s safe… 😈 But: obj.nested.count === 99 💡 The lesson that changed how I code: If you don’t understand how Objects & Arrays behave internally, 👉 You’re not writing predictable code 👉 You’re just “hoping it works” 🎯 What actually makes you a Senior Engineer: ✔ Understanding memory (Stack vs Heap) ✔ Knowing reference vs value ✔ Writing immutable code ✔ Predicting side effects before they happen 🔥 My rule after 12+ years: “If your data is shared… your bugs will be too.” 💬 Curious — what’s the worst bug you’ve faced because of mutation? 👇 Let’s learn from real stories #JavaScript #ReactJS #Frontend #WebDevelopment #Programming #SoftwareEngineering #Coding #Debugging
To view or add a comment, sign in
-
If you know Laravel, you probably haver heard about MVC, right? Here’s a simple breakdown 👇 Model–View–Controller (MVC) is a design pattern that helps you organize your code by separating responsibilities: • Model → handles data and business logic • View → what the user sees • Controller → connects everything and handles requests This separation makes your code easier to maintain, scale, and debug. Once you understand MVC, a lot of frameworks and architectures start to make much more sense. #Laravel #WebDevelopment #Programming
To view or add a comment, sign in
-
-
Here are the 15 essential files every developer should master. 🔐 .env - Your secret keys and environment variables. NEVER commit this to GitHub. 🙈 . gitignore - keep node modules, .env, and build artifacts out of your repo. 🔒 package-lock.json - Locks your dependency versions so everyone on the team runs the exact same code. 🟢 .nvmrc - Pins the exact Nodejs version for the entire team. No more "it works on my machine". 📐 .editorconfig - Consistency indentation and formatting across VS code, webStorm, etc 🔴 .eslintrc - Enforces clean, big Free JavaScript/Typescript rules. ✨ .prettierrc - Ends the tabs vs spaces war forever. 🥘 tailwind.config.js - Custom colors, spacing, and design system in one place. 🔵 tsconfig.json - Controls how Typescript compiles and catches error early. 🌀 .babelrc - Makes modern JS work in older environments. 🐶 .huskyrc - Git hooks that prevent you from pushing broken code. 🦈 .dockerignore - Keeps your Docker images lean and fast. 🌟 .vite.config.js - supercharges your dev server and build process. 🔼 next.config.js - Handles SSR, redirects, images, and all Next.js magic. 🚫 . prettierignore - Tells Prettier which files to leave alone start shipping professional software which one of these did you ignore the longest when you started if I miss any config file drop in the comments save the post for your next project setup #WebDevelopment #Javascript #Typescript #Next #DeveloperTips #CodingBestPtactices #Frontend #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 **ReactJS Project Structure – Standard Folder Setup (2026 Guide)** A clean and scalable folder structure is the foundation of every successful React application. Here’s a quick breakdown 👇 📁 **Root Level** * `node_modules/` – Project dependencies * `public/` – Static files (HTML, favicon) 📁 **src/ (Core Application)** * `components/` – Reusable UI components * `pages/` – Route-level views * `assets/` – Images, fonts, icons * `hooks/` – Custom React hooks * `context/` – Global state management * `App.js` – Root component * `index.js` – Entry point 📁 **Additional** * `tests/` – Test cases * `styles/` – Global styling ⚙️ **Config Files** * `.env` – Environment variables * `package.json` – Dependencies & scripts * `README.md` – Documentation 💡 **Best Practices** ✔️ Keep components reusable ✔️ Separate business logic (hooks/services) ✔️ Maintain clean and scalable structure 📌 A well-structured project = Better performance + Easy maintenance + Faster team collaboration #ReactJS #FrontendDevelopment #WebDevelopment #JavaScript #SoftwareArchitecture #CodingBestPractices #100DaysOfCode #Java #Nodejs #python #DotNet #Csharp
To view or add a comment, sign in
-
-
Only 2% of developers use Full-stack TypeScript with tRPC for true end-to-end type safety. Have you ever wondered why, despite the evolution in tooling and frameworks, bugs still crawl into your codebase after every release? As a developer who's spent countless late nights debugging mysteriously broken interfaces, I’ve turned to Full-stack TypeScript with tRPC for a solution. Type safety isn't just a buzzword; it translates to real-world stability and confidence in code. TypeScript ensures your data contracts remain intact across your entire stack. But here's the kicker: tRPC elevates this synergy to a level where type errors become almost a non-issue. By generating API types directly from your server-side logic, every part of your application - backend to frontend - remains synchronized automatically. Imagine making a server-side change and your editor flagging exactly where you need to adjust your client logic. It's not just time-saving; it's transformative. I remember using vibe coding to quickly prototype features, and it was liberating to see real-time type validations catch potential runtime errors before they became problems. Here's a quick example of how simple it is to define a type-safe API with tRPC: ```typescript import { initTRPC } from '@trpc/server'; const t = initTRPC.create(); export const appRouter = t.router({ greeting: t.procedure .input((val: string) => val.trim()) .query(({ input }) => `Hello ${input}`), }); export type AppRouter = typeof appRouter; ``` This isn't just about using TypeScript; it's about leveraging its full potential to enhance our development workflow. What are your thoughts on adopting full-stack type safety? Are you already using something like tRPC, or is there another framework you find indispensable? Let’s dive into the discussion! #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
-
You're not a developer until you understand these files: • 🔐 .env → Secret keys & env variables. NEVER push to GitHub • 🙈 .gitignore → Files Git should ignore (node_modules, .env...) • 🔒 package-lock.json → Locks dependency versions across all machines • 🟢 .nvmrc → Pins the Node.js version for your whole team • 📐 .editorconfig → Consistent formatting across all editors • 🔴 .eslintrc → Linting rules to keep JS/TS clean • ✨ .prettierrc → Auto code formatting (goodbye tabs vs spaces wars) • 🎨 tailwind.config.js → Custom colors, spacing & themes • 🔵 tsconfig.json → Controls TypeScript compilation • 🔄 .babelrc → Babel config for backward JS compatibility • 🐶 .huskyrc → Git hooks to catch bugs before pushing • 🐳 .dockerignore → Keeps Docker builds clean & lean • ⚡ vite.config.js → Vite dev server & build config • ▲ next.config.js → SSR, redirects & Next.js behavior • 🚫 .prettierignore → Files Prettier should skip 📑 Save this before it disappears... #Developer #tips #tricks #Coding #BestPractices #AI
To view or add a comment, sign in
-
Is your GitHub Actions workflow slower than running the same tests on your laptop? For a long time, my Laravel CI took 8+ minutes on every push. Most of it was Composer reinstalling the same packages over and over. Three changes brought it down to around 90 seconds. 1) Cache Composer dependencies. The official action does 90% of the work: - uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- That single block saved me about 3 minutes per run. 2) Split jobs by responsibility. I used to run lint, static analysis, unit tests, and integration tests as one big sequential job. Splitting them into parallel jobs cut wall-clock time almost in half, and a failing linter no longer blocks the test report. 3) Only run what changed. With paths-ignore, markdown and doc edits stopped triggering the full test suite. Matrix builds run PHP 8.2 and 8.3 side by side instead of sequentially. One flag I wish I had added sooner: --prefer-dist --no-progress --no-interaction on Composer in CI. No TTY, no progress bar, no wasted seconds. CI speed is not a vanity metric. Fast feedback changes how the team behaves: smaller commits, faster fixes, and no more "I'll let CI catch it later" mentality. How long does your Laravel CI take today? What was the single biggest win in your pipeline? #GitHubActions #CICD #Laravel #DevOps #PHP
To view or add a comment, sign in
-
Most production bugs I’ve seen around environment variables aren’t caused by missing values. They’re caused by misunderstanding what environment variables actually are. A few things that have burned teams I know: - Environment variables are an OS primitive. Every process gets a flat key-value copy of its parent’s environment. A copy, not a reference. What your child process changes, your parent never sees. - Your .env file does nothing on its own. Something has to read it. And most tools, including dotenv, will NOT overwrite a variable that already exists. So if your shell profile already exports DATABASE_URL, your .env is silently ignored. This is probably the most common “works on my machine” culprit. - Docker starts with a clean slate. It does not inherit your shell environment. If you’re not explicitly passing variables with -e or –env-file, the container doesn’t know they exist. - React’s process.env is not real runtime config. The bundler replaces every reference with a literal string at build time. That value is now hardcoded in the JavaScript your users download. If you put a secret in REACT_APP_anything or NEXT_PUBLIC_anything, it is not a secret anymore. - Build time and runtime are fundamentally different. A frontend bundle bakes values in at build time. An Express server reads the actual process environment when it starts. You can change a backend variable and restart. You cannot do that with a bundled frontend without rebuilding. Deleted a committed secret in the next commit? The key is still in git history. git show will find it. The only fix is to rotate the credential. The mental model that fixes most of this: secrets always runtime, never build time, never committed to source code. #SoftwareEngineering #DevOps #WebDevelopment #BackendDevelopment #JavaScript #Docker #NodeJS #EngineeringLeadership
To view or add a comment, sign in
-
-
Most developers can recite the definition of OOP. Very few can explain why it actually matters. If you've ever read "Object-Oriented Programming is a paradigm based on objects and classes" and immediately felt more confused than before — that's not a you problem. That's a bad explanation problem. I created this article to change that. OOP in JavaScript: A Beginner's Guide breaks down one of the most misunderstood concepts in programming using clear language, real analogies, and code you can actually follow. What you'll learn: ✅ What OOP actually means — beyond the textbook definition ✅ How to use the blueprint analogy to make classes and objects feel obvious ✅ How to write a class in JavaScript, step by step ✅ What constructors and methods do, and how this ties them together ✅ Why encapsulation matters — with a before/after code comparison ✅ When to use OOP (and when not to) This is part of the Zero to Full Stack Developer: From Basics to Production series — a free, structured path that takes you from zero coding knowledge all the way to building production-grade full stack applications. Read here: https://lnkd.in/gpnAkn7H Follow the complete series: https://lnkd.in/g2urfH2h What JavaScript concept took you the longest to truly understand — and what finally made it click? #WebDevelopment #FullStackDeveloper #Programming #JavaScript #ES6 #SoftwareEngineering #WebDev #TechBlog #LearnToCode
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development