Pragmatism in the real world

Running Spectral lint in Gitlab CI

In my Makefile, I check for OpenAPI spec issues with this command: docker run –rm -it -v $(PWD):/tmp stoplight/spectral lint \ –ruleset /tmp/spec/.spectral.yaml /tmp/spec/openapi.yaml When running in GitLab CI, we set the image to stoplight/spectral:latest, and override the entry point so that we can run spectral directly: openapi-lint: stage: test image: name: stoplight/spectral:latest entrypoint: [""] script: – spectral lint –ruleset spec/.spectral.yaml spec/openapi.yaml Note that GitLab's CI running automatically sets the current working directly to the… continue reading.

Docker Compose DNS entries

Sometimes you need some additional DNS entries in your containers. This is how to do it in compose.yaml. Internal entries Within the containers, the name of the container in compose.yaml is resolvable via DNS. Given this compose.yaml: services: web: # … app: # … networks: myapp: driver: "bridge" We can ping web from within the app container. If we need to access the web container using another domain, we add it as a network alias:… continue reading.

Fixing PhpStorm cannot find a local copy of Standard Input Code

Recently, I set up my PHP dev environment to allow me to step debug from unit tests that I run with make unit The relevant parts of Makefile look like this: # Set DEBUG=1 to enable Xdebug ifeq ($(origin DEBUG),undefined) XDEBUG := else XDEBUG := XDEBUG_SESSION=PHPSTORM endif unit: ## Run unit tests docker compose exec php bash -c "$(XDEBUG) vendor/bin/phpunit –testsuite=unit" I can now set a break point and run the unit tests with Xdebug… continue reading.

Installing the SQL Server PHP extension in Docker on Mac

I'm working on a project that uses MS SQL Server as its database. Recently, I noticed that the SQL Server Docker container now works with Apple Silicon Macs, so looked into setting up a PHP-FPM container with the sqlsrv extension installed. I'm noting the relevant parts of my Dockerfile for when I need them again, so this is entirely an aide-mémoire! FROM ubuntu:22.04 # Install PHP as per https://akrabat.com/7126 ## Register the Microsoft package repository… continue reading.

Prevent the Docker container from taking 10 seconds to stop

For one project that I'm working on the PHP-FPM-based Docker container is built from a Ubuntu container with PHP is installed into it. A little like this: FROM ubuntu:22.04 RUN apt-get update && apt-get upgrade -y && apt-get install -y gnupg curl # Register the Ondrej package repo for PHP RUN mkdir -p /etc/apt/keyrings \ curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg –dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \ && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" >… continue reading.

Damaged application error when developing for Mac

I've been doing a few updates to Daily Jotter, my little Mac app that's available in the Mac App Store. It's been a little while since I last updated it and a few things have changed. After updating the code to fix deprecation warnings, my immediate problem was that the debug version of the app wouldn't start up and I see this error. I know this error well. It means that my app has exited… continue reading.

Changing port maps in Docker Compose

When using Docker Compose, I often map the ports to local ones in the compose.yaml like this: services: web: build: context: ./docker/web ports: – "8080:80" Adding to the port map If port 8080 is in use already on a developer's machine, then we can add a new mapping using compose.override.yaml services: web: build: context: ./docker/web ports: – "8081:80" The compose.override.yaml file is merged with the compose.yaml file and the effective configuration is now: services: web:… continue reading.

Release process checklist

I recently released a new version of rst2pdf. We don't do this frequently and it would be very easy to get it wrong. As a result, we have a RELEASE_PROCESS.rst document in our repo that provides a step-by-step list of what to do. I can't emphasise enough how useful such a document is and every project should have one and I've used them with client projects too. In general the following items need to be… continue reading.

Stash unstaged changes in git

I wanted to stash just the unstaged changes in my git repo. There's a git stash –staged which will stash the staged files, but I didn't see an equivalent to stash just the unstaged ones. Obviously, this is a common problem so a minute or two of googling will find the Git stash uncached: how to put away all unstaged changes? Stack Overflow question. Turns out that you have to remember the the staging area… continue reading.

Using GitHub Actions to add Go binaries to a Release

Shortly after building a script to create binaries for Rodeo, my command line Flickr uploader, I realised that I could use a Github Actions workflow to run it and attach the created binaries to the Release page once I had created it. This is what I did. Trigger on release A GitHub Actions workflow is a YAML file and each workflow has to be triggered. For Continuous Integration, it's common to trigger when new PR… continue reading.