Docker Compose Local HTTPS with nginx or Caddy and mkcert

September 6, 2019 Leave a comment

Why run your project with HTTPS locally?
In most instances, your production site will run with TLS/SSL enabled, ie. over HTTPS. This tends not to be a concern of your application, ie the SSL termination is dealt with at the ingress/reverse-proxy/load-balancer level.

However your application may rely on the assumption that it’s running over an SSL connection. For example, the Set-Cookie header has a Secure attribute which means the cooke will only be sent over a TLS/SSL connection. That means that locally, you would need the code to fork to enable sending of cookie over non TLS/SSL connection, in other words if environment = local => don’t enable Secure.

Categories: Interesting

No networking in Docker containers under Debian 10 — Unixblogger

August 19, 2019 Leave a comment

I finally started to migrate the first few servers to Debian 10, codename “Buster”. With the last upgrades I never stumbled upon any issues. However, this time we see a problem when using Docker as the containers are unable to communicate to the internet. Upgrade to Debian 10 reliable as always As usually, the upgrade…

via No networking in Docker containers under Debian 10 — Unixblogger

Categories: Interesting

Postgres “Select * from ” freezes

August 18, 2019 Leave a comment

Due to a programming error in a python program I had written, I was unknowingly preventing postgres from obtaining an access lock to a table. There were no errors but trying to run a

Select * from <table>

would just freeze.

The solution was to fix the python program. But I used the following query to get some more insight into what was causing the issue.

$ psql -U myuser -h localhost mydatabase
Password for user myuser: 
psql (10.8 (Ubuntu 10.8-1.pgdg14.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.

mydatabase=> SELECT *                                  
  FROM pg_locks l
  JOIN pg_class t ON l.relation = t.oid AND t.relkind = 'r'
 WHERE t.relname = '<table>';
(9 rows)

mydatabase=> \q


Categories: postgresql

25 Useful Basic Commands of APT-GET and APT-CACHE for Package Management

August 14, 2019 Leave a comment

This article explains how quickly you can learn to install, remove, update and search software packages using apt-get and apt-cache commands from the command line. This article provides some useful commands that will help you to handle package management in Debian/Ubuntu based systems.

Categories: bash Tags: ,

Improve your tests in Django with fakes and factories

August 12, 2019 Leave a comment

In our Django apps, we have the M(odel)T(emplate)V(iew) structure (mostly known as MVC). When we want to test its functionality we usually have to create some model instances and work with them and the database.

A nice and easy approach for doing so is to create fake data in our tests in the form of factories and fakers.

In the following article, we are going to look at some practical examples and techniques. This will improve the readability and behavior of your tests.


Categories: python Tags: ,

Using Docker Volumes to Share Data Between Containers and Host Computer

August 4, 2019 Leave a comment

Docker volumes are used to persist data from a certain directory or directories of your Docker containers. So your data is not removed when the container stops or is removed.

You can also share a Docker volume to many containers. Let’s talk about a scenario to find out why it’s important.

Let’s say you have a PHP web application. Now you want to test whether it works on PHP version 5.4, 7.0, 7.1, and 7.2. You can create a Docker volume, let’s call it webapp. Then copy the source code files of your PHP web app to the Docker volume webapp. Then you can create containers of different PHP versions and attach the Docker volume webapp to WEBROOT of all these containers. That way, you can easily test how your web app performs on different PHP versions.

In this article, I will show you how to use Docker volumes to share data between containers and the host computer. Let’s get started.

Categories: Interesting Tags:

How to Set Up a Prometheus, Grafana and Alertmanager Monitoring Stack on DigitalOcean Kubernetes

July 19, 2019 Leave a comment


Along with tracing and logging, monitoring and alerting are essential components of a Kubernetes observability stack. Setting up monitoring for your DigitalOcean Kubernetes cluster allows you to track your resource usage and analyze and debug application errors.

A monitoring system usually consists of a time-series database that houses metric data and a visualization layer. In addition, an alerting layer creates and manages alerts, handing them off to integrations and external services as necessary. Finally, one or more components generate or expose the metric data that will be stored, visualized, and processed for alerts by the stack.

One popular monitoring solution is the open-source Prometheus, Grafana, and Alertmanager stack, deployed alongside kube-state-metrics and node_exporter to expose cluster-level Kubernetes object metrics as well as machine-level metrics like CPU and memory usage.

Rolling out this monitoring stack on a Kubernetes cluster requires configuring individual components, manifests, Prometheus metrics, and Grafana dashboards, which can take some time. The DigitalOcean Kubernetes Cluster Monitoring Quickstart, released by the DigitalOcean Community Developer Education team, contains fully defined manifests for a Prometheus-Grafana-Alertmanager cluster monitoring stack, as well as a set of preconfigured alerts and Grafana dashboards. It can help you get up and running quickly, and forms a solid foundation from which to build your observability stack.

In this tutorial, we’ll deploy this preconfigured stack on DigitalOcean Kubernetes, access the Prometheus, Grafana, and Alertmanager interfaces, and describe how to customize it.

Categories: Interesting Tags: