Jeremy Kreutzbender

Jeremy Kreutzbender

Hello I'm Jeremy. You can find me around the internet as j_kreutzbender or jer-k. I'm mostly thinking about Ruby & Rails, Elixir & Phoenix, Docker, and DevOps topics when it comes to programming.
I currently work remotely in Portland, OR at Release.
Programming

Secure Docker Authentication with Pass on Alpine Linux

insecure docker login

If you’ve ever encountered the above message when logging into Docker and thought to yourself “Well it’s unencrypted but it works… I’ll deal with it another day” then we’ve got something in common. That day finally came when I was working on another blog post but realized that without a secure way to do a docker login I was never going to achieve a good working example to write about. I came across docker-credential-helpers which looked like exactly what I needed. One of the recommended ways to store the…

Read More >>
Programming

Github Action to upload SimpleCov Coverage Results

What a wonderful day that was! I’ve been playing around with Actions ever since and one of my new projects, a Ruby Gem, didn’t have any form of CI as of this morning. I set out to create an Action that would run the tests for the gem and produce coverage results via SimpleCov. While it’s nothing too extravagant, there was a small nuance that I had to resolve and I decided I wanted to share that info.

Let’s start off with some changes to the SimpleCov configuration.

if ENV.fetch('COVERAGE', false) SimpleCov.start do minimum_coverage 90 maximum_coverage_drop 2 end end

This ensures that the coverage is above 90% and any changes in the future must not drop the coverage by more than 2%. The Gem, in its infancy, does not pass this requirement. Due to that failure, I had to figure out why the Action was not uploading the coverage results. Remember to put the SimpleCov code at the very top of spec_helper.rb, before you do require 'your_gem'

Read More >>
Programming

Authenticate Github's Webhooks API using Elixir's Plug

Recently, I started working on a new side project in Elixir and I think I’ve finally found something I’m going to stick with! In the past I would either build something like a simple TODO app and not get far enough into the language or I would pick a gigantic idea and get nowhere due to how daunting it was. However, one of my co-workers recently implemented a feature through the Github Webhooks API where we are required to add a label to our Pull Requests and a Slack channel is notified that the…

Read More >>
Thoughts

My First Ten Years; My Next Ten Years

I was recently attending DockerCon and Michael Ellison, CEO of Codepath, was giving a talk about the future of Computer Science education. He was telling a story about how he was recently in a room with a large number of CTOs and asked how many of them started programming before the age of 14. He mentioned that around 90% of them raised their hands. I let out an audible chuckle, turned to the person next to me and said “Well time to change careers, looks like I’ll never be a CTO.” While being a…

Read More >>
Programming

Postgresql Docker Image with Seeded Data

Recently, I decided that one of my goals for 2019 was to familiarize myself more with Docker. I’ve been exposed to using Docker for the past couple of years, but I don’t use it on a day to day basis. Every once in a while, I would need to update a Dockerfile or a script and I would realize I needed to brush up on mostly everything because it had been so long since the last time I looked at anything Docker related. I decided I would just dive in and read a book to familiarize myself with any…

Read More >>
Programming

Update - Ruby Gem Dockerfile with Alpine Linux

An update to my post on adding a testing environment to a gem. After doing some recent updates to our Docker images at work, I realized that we are always using Ruby Alpine images, and not the base Ruby image. I can’t remember why I built the gem’s Dockerfile using the base Ruby image, perhaps I had just overlooked the fact that we used Ruby Alpine, but I wanted to standardize the Dockerfiles I had written at work and here for the blog so I decided to look into what it would take to do so.

First…

Read More >>
Programming

Adding a Test Environment to the Active Record Rake Tasks Gem

Continuing to work on our gem with active_record rake tasks, we still need to set up a testing environment that can be run locally and in a repeatable fashion for continuous integration; we’ll accomplish the latter using a simple Dockerfile. But first let’s make it easier for someone to start using the gem by enhancing the scripts in bin/.

We’ll start off by changing bin/setup to create the user and the database.

#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' set -vx bundle install psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='gem_with_database'" | grep -q 1 || \ psql -c "create role gem_with_database with superuser login password 'password'" psql -tAc "SELECT 1 FROM pg_database WHERE datname='gem_with_database_development'" | grep -q 1 || \ rake db:create db:migrate db:seed

The first command queries the pg_roles table looking to see if there is a role named gem_with_database and returns 1 if so. The result is piped into grep looking for the 1, if it is found we stop, otherwise we issue another command to create the gem_with_database role. If you’re curious as to how this works, grep returns a non-zero exit code if it doesn’t find something and a bash ||

Read More >>
Programming

Adding Rails G Migration To a Gem - Following Code To Re-Implement Functionality

This is a follow up to my last post about Adding ActiveRecord Rake Tasks to a Gem that I promised to write. In that post I had to figure out how to make the command rails g migration accessible inside of the gem, which ended up taking me all afternoon, but surprised me in how little code was actually needed to achieve the result. I wanted to write about the process I went through to figure out what was needed; I believe it is good exercise in understanding how to follow code to and understanding what it takes to…

Read More >>
Programming

Adding ActiveRecord Rake Tasks to a Gem

In my previous post I walked through using a gem to connect to another Rails application’s database, but another use case for connecting a gem to a database is for the development of the gem itself. Instead of having to create a Rails application and install the gem to connect to the database to test your models, we can create local database for only the gem by adding ActiveRecord’s Rake tasks.

There will be a lot to go through so I’m going to break this down into two parts: the first being creating the gem and enabling the usage of familiar tasks such as db:create and db:migrate, the second being setting…

Read More >>