Running a Docker container as a non-root user

The Problem: Docker writes files as root Sometimes, when we run builds in Docker containers, the build creates files in a folder that’s mounted into the container from the host (e.g. the source code directory). This can cause us pain, because those files will be owned by the root user. […]

How to run single test method with phpunit?

The following command runs the test on a single method: phpunit —filter testSaveAndDrop EscalationGroupTest escalation/EscalationGroupTest.php phpunit —filter methodName ClassName path/to/file.php For newer versions of phpunit, it is just: phpunit —filter methodName path/to/file.php

Docker — Ubuntu — bash: ping: command not found

Docker images are pretty minimal, But you can install ping in your official ubuntu docker image via: apt-get update apt-get install iputils-ping Chances are you dont need ping your image, and just want to use it for testing purposes. Above example will help you out. But if you need ping […]

Use constraints with Swarm mode

In this post, i will explain you how to use constraints to limit the set of nodes where a task can be scheduled. It’s the purpose of a Swarm cluster, all your nodes can accept containers. But sometimes, you need to specify a subset of nodes for some reasons. For […]

How to add a Watermark to an image with Imagick in PHP

Basically, all that you need to add a watermark to an image is the compositeImage method from an image object. This method allows you to easily composite one image onto another. <?php // Create instance of the original image $image = new Imagick(); $image->readImage(«image.jpg»); // Create instance of the Watermark […]

Паттерн: Сага

Есть приложение, к которому применялся паттерн Database per Service. Теперь у каждого сервиса приложения есть своя собственная база данных. Некоторые бизнес транзакции охватывают сразу несколько сервисов, так что нужен механизм, обеспечивающий согласованность данных между этими сервисами. Например: давайте представим, что мы разрабатываем интернет магазин, где у клиента есть кредитный лимит. […]

Шаблон распределенных транзакций Saga

Шаблон проектирования Saga — это способ управления согласованностью данных между микрослужбами в сценариях распределенных транзакций. Saga — это последовательность транзакций, которая обновляет каждую службу и публикует сообщение или событие для активации следующего шага транзакции. Если шаг завершается ошибкой, Saga выполняет компенсирующие транзакции, которые отменяют предыдущие транзакции. Контекст и проблема Транзакция […]