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

The Difference Between Git, GitHub, GitLab (And Others)

Posted by Daniel Wachtel in Basics, last updated on 20 June, 2021

Introduction

When you first start programming you’ll often hear that you should always version control your code.

You’ll also hear words thrown around such as Git, GitHub, GitLab and similar services.

If you’re not sure what the difference is I’ll be breaking it down in this post, but first a high level overview of the difference between them:

Git is an open source distributed version control system (DVCS) that allows developers to work on the same project from anywhere and even if they’re offline. GitHub, GitLab and their alternatives are cloud services that provide remote hosting of Git repositories, as well as features such as task management, wikis, CI and more.

Let’s break it down further.

Read more

Building an RSS Feed with Phoenix

Posted by Daniel Wachtel in Phoenix, last updated on 10 October, 2020

Introduction

I wanted to add an RSS feed to this blog but decided that instead of installing a dependency I’ll build one myself! Here’s how you can set one up in a Phoenix application:

Creating the RSS view

First let’s define a new route in lib/your_app_web/router.ex:

scope "/", YourAppWeb do
  ...

  get "/rss", RSSController, :index
end
Read more

Dockerizing a Ruby on Rails app with a PostgreSQL Database

Posted by Daniel Wachtel in Rails, last updated on 06 September, 2020

Introduction

These are the configurations I use to deploy a Rails 6 app. Note that this is a small hobby app so I’m using docker-compose to deploy it, for more serious apps you’d want to use docker swarm or kubernetes.

If you don’t have a server ready or docker and docker-compose installed on your local dev machine then have a read through this blog post first.

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

Read more

Adding Global View Helpers to a Phoenix Application

Posted by Daniel Wachtel in Phoenix, last updated on 06 September, 2020

Introduction

If you come from a Ruby on Rails background you might be used to having view helpers such as number_with_delimiter up your sleeve and ready to use in any view.

Here’s how to configure functions that are accessible in your Phoenix views:

1) Create a helper module

I usually create a helpers directory under the app_name_web directory. Next create a new module, let’s call it application_helper.ex:

Read more

Enabling GZIP Compression on a Phoenix Application

Posted by Daniel Wachtel in Phoenix, last updated on 27 August, 2020

The issue

The other day I ran my blog through GTmetrix website speed test and realised that I had turned on GZIP compression for static assets, but not for dynamic content. This is easily fixed however with 2 lines of code:

Enabling GZIP compression for static assets

To enable compression for static assets add gzip: true (or gzip: Mix.env == :prod for production only) to the Plug.Static config in lib/your_app_web/endpoint.ex:

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