Docker Swarm healthchecks - checking for file presence

Posted by Daniel Wachtel in DevOps, last updated on 05 March, 2025

Docker swarm configuration

Recently I deployed a service that has no HTTP endpoints, instead I created a file in the container on startup that is deleted when the service is unhealthy.

Here is the config to check for the file presence, once deleted and the healthcheck fails a few times the service will be restarted:

deploy:
   replicas: 1
   restart_policy:
     condition: on-failure
    healthcheck:
      test: ["CMD", "test", "-f", "/path/to/file"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

Read more

How to build Linux Docker images on a Mac

Posted by Daniel Wachtel in DevOps, last updated on 05 March, 2025

The command

This is a short snippet I use to build and push Linux Docker images on my M1 Macbook Air.

docker buildx build --platform linux/amd64 \
  -t <namespace>/<repository>:<tag> \
  -t <namespace>/<repository>:latest . \
  --push

I’m tagging the image twice, once with a unique tag and once with latest. This is so that I can use the latest tag in my CI/CD pipeline but don’t lose the image history in my registry in case I need to roll back.

Read more

Deploying multiple apps to a single DigitalOcean droplet using Dokploy

Posted by Daniel Wachtel in DevOps, last updated on 05 March, 2025

Introduction

Dokploy is a free, self-hostable Platform as a Service (PaaS) that simplifies the deployment and management of applications and databases.

It’s a great tool for deploying multiple apps to a either a single or multiple DigitalOcean Droplets.

It has many features including:

Before you start first spin up a DigitalOcean Droplet and secure it using the steps here.

Read more

Securing a DigitalOcean Linux Server (Droplet)

Posted by Daniel Wachtel in DevOps, last updated on 10 March, 2025

Introduction

For most of my hobby projects I use DigitalOcean’s Droplets, which are scalable virtual private server (VPS) that you can use to host your own applications and services.

They’re easy to spin up either for testing or production and are relatively cheap.

But if you’re planning to use them for more than just testing you should take some basic steps to secure your server.

Read more

Dockerizing a WordPress site with a MySQL database

Posted by Daniel Wachtel in DevOps, last updated on 03 May, 2020

Introduction

I had a couple of WordPress sites I wanted to dockerize and move over to my new server. This is the configuration I used to deploy them to my new server as described here.

I’m using the official wordpress and mysql images and don’t need to build anything, so all I need to deploy the app is a docker-compose.yml file and a couple of .env files.

The docker-compose.yml file

I’m using the wordpress:5.4.1 (also tagged as wordpress:5.4.1-apache) which uses an Apache server and serves the app on port 80. Port 8080 is mapped to my host.

Read more

Dockerizing a Matomo (formerly Piwik) web analytics app

Posted by Daniel Wachtel in DevOps, last updated on 03 May, 2020

Introduction

Matomo (formerly known as Piwik) is an open source web analytics application that runs on PHP and a MySQL database, which I’ve been using instead of Google Analytics.

This is the configuration I use to deploy it as described here.

I’m using the official matomo and mariadb images and don’t need to build anything, so all I need to deploy the app is a docker-compose.yml file and a .env file.

Read more

Dockerizing a Phoenix app with a PostgreSQL database

Posted by Daniel Wachtel in DevOps, last updated on 01 September, 2020

Introduction

These are the configurations I use for a Phoenix 1.4 app to deploy it to production using docker-compose contexts. If you don’t have a server ready or docker and docker-compose installed on your local dev machine then have a read through that blog post first.

For this build I’m not going to dockerize NGINX as I have it installed on the server.

Create a Dockerfile

Step one is to create a Dockerfile in the root directory of your project. For this build I’ll be using elixir:X.X.X-alpine image. alpine is a much slimmer Linux docker image and will reduce our overall image sizes.

Read more

Deploying multiple dockerized apps to a single DigitalOcean droplet using docker-compose contexts

Posted by Daniel Wachtel in DevOps, last updated on 03 March, 2025

Introduction

In this post we’ll go over setting up a DigitalOcean Droplet to run multiple dockerized apps which we’ll deploy to production using docker-compose and docker contexts. We’ll also set up NGINX reverse proxies for the apps we want to expose externally.

Using docker-compose with contexts lets us run builds and deployments to remote servers from our local dev machine. This feature is available to docker-compose starting with release 1.26.0-rc2.

Note: this feature is relatively easy to use, especially if you’ve used docker-contexts before however is more suited for deploying small/hobby apps to a single server. There will be some downtime as you’re releasing new builds (generally a few seconds) so if you require zero downtime deployments, rolling updates and multiple server orchestration then you should look at docker’s swarm feature or kubernetes.

Update: I’ve now published a better way of deploying multiple apps to a single DigitalOcean droplet. Check it out here: Deploying multiple apps to a single DigitalOcean droplet using Dokploy.

Read more