GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • febus982/bootstrap-python-fastapi
  • Home
  • API Documentation
  • Application architecture
  • Zero Trust architecture
  • Inversion of Control
  • Multistage Dockerfile
  • Alembic
  • Bootstrap
  • Domains
  • Dramatiq worker
  • Gateways
  • HTTP App
  • Summary

This view

  • Original page
  • New address

GeezerVison is showing febus982.github.io — Multistage Dockerfile - Bootstrap python fastapi

Multistage Dockerfile

Python docker image tend to become large after installing the application requirements (the slim base is ~150 MB uncompressed), therefore it's important to spend efforts to minimise the image size, even if it produces a slightly more complex multistage Dockerfile.

The implemented Dockerfile makes sure the production image will keep to a minimal size ("only" 360MB): * 150MB base image * 210MB python installed dependencies

If you look at the "dev" image is instead ~850MB, more than 400MB that would end up as a cost in traffic on each image pull.

flowchart TD
    subgraph BASE
      base["Base
      ====
      Contains system runtime
      libraries necessary to run
      all the applications
      (e.g. libmysql)"]

      base_app["Base app
      ========
      Copies shared application logic
      independent from the used framework
      (domains, storage, etc.)"]

      base_builder["Base Builder
      ============
      Contains system libraries
      necessary to build python
      dependencies
      (e.g. gcc, library headers)"]

    end

    dev["Dev
    ===
    Fat image containing everything
    for local development"]

    base-->base_app
    base-->base_builder
    base----->dev

    subgraph HTTP
      http_builder["HTTP builder
          ============
          Installs requirements for
          HTTP app in a virtualenv"]
      http_app["HTTP app
        ========
        Copies HTTP app,
        shared logic
        and requirements
        from previous containers"]
      http_builder-->http_app
    end

    subgraph Dramatiq
      dramatiq_builder["Dramatiq builder
          ============
          Installs requirements for
          Dramatiq worker in a virtualenv"]
      dramatiq_app["HTTP app
        ========
        Copies Dramatiq worker app,
        shared logic
        and requirements
        from previous containers"]
      dramatiq_builder-->dramatiq_app
    end

    base_builder-->http_builder
    base_builder-->dramatiq_builder
    base_app-->http_app
    base_app-->dramatiq_app
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.