5 Docker mistakes I see in every Python project I've reviewed dozens of Dockerfiles for Django and FastAPI apps. The same problems keep showing up: 1️⃣ Using python:latest as base image → It's 900MB+. Use python:3.12-slim. Your builds will be 3x faster and your images 4x smaller. 2️⃣ Not using .dockerignore → Your .git folder, __pycache__, .env files — all ending up in the image. Slower builds, potential security risk. 3️⃣ Installing requirements before copying code → Layer caching exists for a reason. Copy requirements.txt first, install deps, THEN copy your code. Every code change won't rebuild all dependencies. 4️⃣ Running as root → Add a non-root user. It takes 2 lines and prevents an entire class of security issues. 5️⃣ No health checks → Your container is "running" but your app crashed 10 minutes ago. Add HEALTHCHECK — let Docker know when something is actually wrong. Fix these five things and your Docker setup goes from "it works on my machine" to production-ready. Which one are you guilty of? 👇 #Docker #Python #DevOps #BackendDevelopment #SoftwareEngineering
Artur Keraz’s Post
More Relevant Posts
-
5 Docker mistakes I see in every Python project I've reviewed dozens of Dockerfiles for Django and FastAPI apps. The same problems keep showing up: 1️⃣ Using python:latest as base image → It's 900MB+. Use python:3.12-slim. Your builds will be 3x faster and your images 4x smaller. 2️⃣ Not using .dockerignore → Your .git folder, __pycache__, .env files — all ending up in the image. Slower builds, potential security risk. 3️⃣ Installing requirements before copying code → Layer caching exists for a reason. Copy requirements.txt first, install deps, THEN copy your code. Every code change won't rebuild all dependencies. 4️⃣ Running as root → Add a non-root user. It takes 2 lines and prevents an entire class of security issues. 5️⃣ No health checks → Your container is "running" but your app crashed 10 minutes ago. Add HEALTHCHECK — let Docker know when something is actually wrong. Fix these five things and your Docker setup goes from "it works on my machine" to production-ready. Which one are you guilty of? 👇 #Docker #Python #DevOps #BackendDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
Just shipped stup 🚀 A python package that scaffolds production-ready Python projects in seconds. 🛠️ Every time I started a new project, I was doing the same thing: init uv, pin Python, create venv, wire up requirements.txt, set up folders. 10 minutes of setup before writing a single line of actual code. ⏳ stup kills that loop. One command, full scaffold⚡ → `stup django` : Django + DRF + Celery + Redis + PostgreSQL, ready to go → `stup lang-agent` : LangGraph agent with tools, memory, Ollama config → `stup react-fastapi` : Full-stack with Docker Compose and CORS pre-wired → `stup ml` : MLflow + PyTorch + scikit-learn experiment structure → `stup cli` : PyPI-ready package with Typer + Rich, entry_points set All templates build on top of `stup uv` which handles uv init, Python pinning, and venv in one shot. Install once: `pip install stup` source code: https://lnkd.in/duGUCXVH
To view or add a comment, sign in
-
-
Your Django API is not slow because of your database. It's slow because of serialization. A 17-field serializer on 1,000 records = 17,000 Python calls. Just to produce JSON. We hit this in a rental platform in Stockholm. 80ms → 3 seconds at 2,000 users. So we built ClaraX — Rust serialization for Django. One line. No rewrites. No Rust knowledge. Results: → 475ms → 14ms (33x) → 506ms → 10ms (50x) pip install clarax-django python manage.py clarax_doctor https://lnkd.in/dgmZgnK5
To view or add a comment, sign in
-
-
PySpector v0.1.8 is out🚀 Me and the PySpector Core Team worked really hard to deploy this version, so here's what changed: - A new vulnerability leading to arbitrary code execution via plugin bypass was patched (and its #GHSA was published) - Docs were updated and improved🫡 - We fixed a bug preventing the generation of html reports, as well as 2 other bugs preventing the --wizard and -- supply-chain flag from working properly - We expanded error messages during #AST file parsing and added a new #CLI flag to enable Python SyntaxWarnings during code scanning - And last we (finally) expanded support for Python up to the latest #Python3.14 (while before v.0.1.8, Python support stopped at #Python3.12) Thanks to all the #contributors and the awesome SecurityCert community who made this possible🫶 Repo: https://lnkd.in/d7CppftJ
To view or add a comment, sign in
-
I pretty much start every Python project with a pyproject.toml. It keeps things simple: - One place for configs - Easy for VSCode to pick up - Easy to reuse in CI/CD pipelines - No environment variables to set up - No manual setup for installs and dependencies But I ran into a subtle issue while using it inside a DevContainer. Everything looked fine: - Project structured correctly - pyproject.toml in place - Virtual environment set up But imports started behaving inconsistently. What made it tricky was that nothing was obviously broken. So I went back to basics: - checking where Python was actually importing from import my_package print(my_package.__file__) That’s when it clicked. The DevContainer was picking up a previously installed version of the project instead of my current code. The fix ended up being: - installing the project in editable mode pip install -e . After that, imports consistently pointed to the working directory instead of a stale installed version. Big takeaway for me: Even with a clean pyproject.toml, how your project is installed matters just as much as how it’s defined. Lately I’ve been focusing more on making my dev environment predictable, not just “working” Curious how others handle this: Do you always install your project in editable mode during development? #DevOps #Python #Docker #VSCode #SoftwareEngineering
To view or add a comment, sign in
-
Flask vs Django: Key Differences Every Python Developer Should Know #programming #webdesign #rswebsols https://ift.tt/bB6T4co Excited to share our latest dive into Python web frameworks: Flask vs Django. This post breaks down the key differences every developer should know, from project size and complexity to learning curves, speed of development, and ecosystem strength. If you’re choosing the right tool for your next project, this comparison will help you make an informed decision between Django’s batteries-included approach and Flask’s lightweight, flexible design. Read the full analysis and decide which framework aligns with your goals and team needs. Link: https://ift.tt/bB6T4co
To view or add a comment, sign in
-
-
🚀 Day 01 of 30 — Advanced Python + Real Projects I used @app.route() for 2 years before I understood what was actually happening. Turns out? It's just a decorator. And decorators are just functions wrapping functions. But here's what nobody tells you — Every serious Python framework you've ever used is built on this one pattern: → Flask uses it for routing → FastAPI uses it for dependency injection → Django uses it for auth (@login_required) → Celery uses it for task registration → Pytest uses it for fixtures Once you truly understand decorators, you stop being a framework user. You start being a framework reader. ✅ Why decorators exist (the real reason) ✅ The "onion model" mental model ✅ 4 types used in production ✅ Fully annotated syntax breakdown ✅ Real e-commerce API example with auth + cache + rate limiting ✅ Common mistakes senior devs still make ✅ Performance tips from real systems 💡 Key insight: "A function that needs 5 decorators probably has 5 responsibilities that aren't the function's fault." Save this. You'll need it. 🔖 #Python #PythonProgramming #SoftwareDevelopment #BackendDevelopment #Programming #CodeNewbie #Developer #TechLinkedIn #PythonDeveloper #LearnPython #SoftwareEngineering #CodingLife #100DaysOfCode #FastAPI #Django #OpenSource #TechContent #LinkedInLearning #DataEngineering #PythonTips #PythonTutorial
To view or add a comment, sign in
-
Your unittest.mock is lying to you. Tests pass in CI, production breaks, and nobody knows why. The problem? Hand-written mocks drift from the real API silently. I've been contributing to the Microcks open-source ecosystem, and I want to share my latest work on Microcks Testcontainers https://lnkd.in/edzprW5k family for Python. Microcks Testcontainers takes a different approach: your OpenAPI spec becomes the mock. Load it into a Microcks container inside your test suite, and it: - Mocks your dependencies using spec-defined examples - Contract tests your implementation against the spec - Catches API drift automatically I also built a demo app with Flask showing the pattern end-to-end. Library: https://lnkd.in/eXyXwpnB Demo app (Flask): https://lnkd.in/eRhXfKeZ Full step-by-step guide: https://lnkd.in/eBvxUJy8 #Python #Testing #Microservices #API #OpenAPI
To view or add a comment, sign in
-
Type errors in Python only surface when the faulty code path actually executes at runtime. A function that receives the wrong argument type can pass an entire test suite — then fail in production on a condition nobody anticipated. mypy catches that class of error before any code runs. But many articles stop at "add annotations and run mypy." The mechanics of how it actually works stay opaque. The article linked below (on PythonCodeCrack) goes further: — The full analysis pipeline: AST parse → import resolution → type inference → contract checking, with no execution involved — How gradual typing works in practice, including what the Any type actually does to mypy's analysis downstream — A precise look at type narrowing and control flow analysis — with an interactive diagram showing how isinstance() resolves str | int into concrete types per branch — The difference between # type: ignore and cast() — and why using the wrong one silently breaks your type guarantees for all code that follows — What mypy 1.20 changed: the narrowing engine rewrite, fixed-format cache as the new default, and the experimental Ruff-based parser — How pyright and ty differ from mypy architecturally — not just in speed benchmarks, but in evaluation strategy and what that means for unannotated legacy code Written for developers who want to understand the tool, not just run it. https://lnkd.in/e838Mdu5 #Python #SoftwareEngineering #TypeHints
To view or add a comment, sign in
-
🚀 Day 17 – Python API Integration Today I explored the power of Django REST Framework and how it simplifies building RESTful APIs in Python. 🔹 Key takeaways: Understood how Django REST Framework extends Django to build APIs efficiently Created a Django project and app structure (countryapi, countries) Built a Model (Country) to represent data Learned how Serializers convert Django models into JSON Used ModelViewSet to handle CRUD operations automatically Configured DefaultRouter to generate API endpoints 🔹 Implemented API endpoints: GET → Retrieve countries POST → Create new country PUT / PATCH → Update data DELETE → Remove data 💡 What stood out: Django REST Framework reduces a lot of boilerplate by providing built-in tools for serialization, routing, and request handling — making API development faster and more structured. 📌 This is a big step forward in building production-ready backend systems. #Python #DataEngineering #Django #DjangoRESTFramework #APIs #BackendDevelopment #LearningJourney #selfLearning
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