PHP basic auth file_get_contents()

You will need to add a stream context to get the extra data in your request. Try something like the following untested code. It’s based on one of the examples on the PHP documentation for file_get_contents(): $auth = base64_encode(«username:password»); $context = stream_context_create([ «http» => [ «header» => «Authorization: Basic $auth» […]

Traefik not issuing certs in HA cluster

Traefik eventually started working on it’s own. Might have been a lingering lock that needed to expire or something. I added the following to the Traefik Consul policy key_prefix «traefik/» { policy = «write» } session «» { policy = «write» } session_prefix «» { policy = «write» } I’ll […]

Настройка Преобразования DNS с Помощью «resolv.conf» в Примерах

Файл настроек /etc/resolv.conf содержит информацию, которая позволяет компьютеру преобразовывать буквенно-цифровые доменные имена в цифровые IP адреса. При использовании DHCP, dhclient обычно перезаписывает resolv.conf информацией полученной от DHCP сервера. Как редактировать файл «/etc/resolv.conf»? Используйте текстовые редакторы, такие как vi или gedit, в Linux: # vi /etc/resolv.conf В /etc/resolv.conf настраиваются три основные […]

Микросервисная архитектура в разрезе

Использовать микросервисную архитектуру или нет? Разбираемся с плюсами и минусами, внутренней коммуникацией, принципами и заблуждениями. Виды архитектуры Простейший и популярный вариант архитектуры – монолитная. Каждый начинал с неё, и здесь нет никакой изоляции и распределённости: один монолит обрабатывает все запросы. Отчего возникают следующие проблемы: отказоустойчивость; горизонтальное масштабирование; применение одной технологии или языка […]

Composer/PSR — How to autoload functions?

After some tests, I have came to the conclusions that adding a namespace to a file that contains functions, and setting up composer to autoload this file seems to not load this function across all the files that require the autoload path. To synthesize, this will autoload your function everywhere: […]

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 […]