Building a Python Application Docker Image with Multi-Stage Builds

This article describes how to build a Python application Docker image, optimized for production use, using multi-stage builds.

The idea is to use a separate build stage to build the dependencies (where the build process itself may require other dependencies, like build tools, compilers, header files, etc.), then copy the …

more ...

Django Migrations on Kubernetes

Concurrent setups are helpful for scalability and performance, but may bring complexities for consistency. Not all tasks benefit from concurrency though. For example running database migrations is a task where consistency and controlled execution is more important than concurrent execution, if that's desired at all.

In a distributed setup, how …

more ...

Python Context Managers

Date Tags python

Sometimes it's helpful to wrap some code in a given context. Either the code requires some resource from the context, or the context adds some aspect to the code.

Python provides with statement to create a context for the followed block of code.

with context_manager:
    # this block runs within the …
more ...

Linux Home On Encrypted Partition

Date Tags linux

Goal: Mount an encrypted partition on a secondary disk to /home.

I needed more space for user files on my Linux desktop running on an SSD, so I wanted to use a second rotating disk to store user files. I also wanted to encrypt this disk.

Procedure

  1. Create the encrypted …
more ...

Python Methods As Decorators

Python function decorators (PEP 318) make it easy to modify behavior of functions (or add new functionality), without changing them. We won't introduce them here as they're documented extensively.

We're demonstrating a specific case, where we have a class and we want to to use one of the methods of …

more ...

Skipping Tests

Sometimes a test should be skipped for a good reason (some resource is not available for a while and mocking is not an option, or tests are assumed to be impacting each other, etc.).

Most test runners support a way to mark a test to be skipped in a proper …

more ...

Mixed DDL and DML SQL Commands in Doctrine Migrations

Doctrine is a useful library when working on a heavy DB dependent application in PHP/HackLang. It provides migrations as a tool to ease the process of applying changes to the database.

Each migration version is a class (often extends an abstract migration class provided by Doctrine), which specifies the …

more ...

Python Virtual Environments

Date Tags python

Problem: Different applications might require different versions of the same libraries, which version of those libraries should be installed?

Problem: There are tools installed with the operation system written in Python, they require specific versions of some libraries, and the ones provided by the operating system packages are to satisfy …

more ...

Programming

Date

Programming is a creative and challenging process, and this makes it interesting. There is so much to learn and there is so much to do. But this is common to get lost in this ocean and forget what was the original destination. Software programs exist to solve problems and empower …

more ...