Skip to content →

Chris Stump Online Posts

Let’s Encrypt a Dockerized Rails Application

If you have, or plan to launch, a public facing website that asks users to log in then you need to be using HTTPS. Users expect security, and it’s the least you can provide if you’re asking them for their data. That said, SSL is traditionally a big pain in the ass. It’s not easy to setup and a trusted certificate can cost hundreds of dollars. Luckily all that has changed thanks to Let’s Encrypt and their ACME protocol .  As mentioned on the about page, “Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit.” In other…

Continue reading Let’s Encrypt a Dockerized Rails Application

11 Comments

Postgres Container Access with a SQL Client

 As you may have read I like to use Postgres’ official image in my multi-container Docker environment. Out of the box it needs little configuration. I typically access it through my Rails app using  rails db or  rails console . The other day, however, I needed to craft some SQL and those tools weren’t cutting it. I wanted to use my SQL client so I could work directly with the schema on something better than the command line. That required some tweaking to my DB container. By default the Postgres image uses Docker’s EXPOSE instruction to open port 5432 for other Docker containers. EXPOSE does not make the port…

Continue reading Postgres Container Access with a SQL Client

Leave a Comment

Please Stop Abusing NotImplementedError

The purpose of NotImplementedError is defined in the Ruby docs: NotImplementedError is raised when a feature is not implemented on the current platform. For example, methods depending on the fsync or fork system calls may raise this exception if the underlying operating system or Ruby runtime does not support them. So whenever I see code like this:

I cringe. Raising NotImplementedError simply to signal that a subclass didn’t abide by the contract of its superclass is an abuse of the error. The error is intended to be raised when a method cannot be implemented due to a limitation of the underlying…

Continue reading Please Stop Abusing NotImplementedError

2 Comments

Continuous Deployment of a Dockerized Rails Application

I believe continuous deployment is a worthy goal for every development team. The practice requires discipline and minimizes the risks associated with releasing large swaths of new code into the wild. I agree with the mantra that deployments shouldn’t be a big deal; that they should be easy to roll back from, and require little ceremony. This tutorial is the last in a series of three that demonstrates how to use Docker in development, continuous integration, and continuous deployment. Follow all three and you’ll have a system where you can push code to master, watch your tests run in CI,  and then have…

Continue reading Continuous Deployment of a Dockerized Rails Application

20 Comments

Continuous Integration of a Dockerized Rails Application

If you’ve ever worked with continuous integration then you know it’s a valuable tool. Having a CI server run your test suite after each push to a branch is great for discovering integration bugs and for building team confidence. Maintaining a traditional CI server, however, can be a pain. It’s close to, but not quite, a production environment, and it is not a development environment. Instead it’s a nuanced version of both. That difference inevitably leads to someone saying “tests passed on my machine, not sure why they are failing in CI.” If you don’t want to hear those words then I suggest you…

Continue reading Continuous Integration of a Dockerized Rails Application

Leave a Comment

Docker Image Reduction Techniques and Tools

Yesterday I spent some time researching how to reduce the size of my Docker image. Weighing in at 841.6 MB while loaded my Rails application image is probably average sized. Docker Hub reports it as 338 MB which is approximately the size of the image after I have docker saved and gzip’d it. That tells me that docker push  and docker pull are transporting much lighter files than I work with on a daily basis. That’s good, but smaller images mean faster deploys, so time researching how to lighten their load seemed worthwhile. Known techniques for reducing Docker image size There are some decent articles that discuss Docker image size in depth…

Continue reading Docker Image Reduction Techniques and Tools

10 Comments

Docker for an Existing Rails Application

A few weeks ago I decided to take an existing Ruby on Rails application and configure it to work with Docker. I wanted a container-based development environment that fed into a continuous integration to continuous deployment pipeline. The hope is that this style of development would eliminate the differences in environment you typically find between work laptops running OS X and staging, testing, and production servers running Linux. I also wanted to simplify server configuration and maintenance, plus make it super easy for another person to jump on the project. Docker delivers on all these hopes, but with so many different ways to use Docker…

Continue reading Docker for an Existing Rails Application

66 Comments

ActiveRecord Coerces Values Set with #id= into Fixnum

I found a bug in my code today that stems from my not remembering that ActiveRecord::Base will try to coerce values set on its attributes into whatever type is defined in the DB. Specifically I got burned by #id= coercing a String into a Fixnum. Check this out:

Not only is the type of object changed by setting the attribute but the leading zero is lost. Luckily my specs caught this. I know, I know it’s a bad idea to set #id yourself. You should let ActiveRecord do that for you. In my case I was trying to cleverly avoid…

Continue reading ActiveRecord Coerces Values Set with #id= into Fixnum

Leave a Comment

Rails Production Eager Loading Ignored by Rake Tasks

I got bit by the Rails production environment today. Here’s the scenario: I have a set of classes that all mixin the same module.

Upon include the module “registers” the class with another class

Once registered subclasses of ApiCheck  can perform actions using the registry. Those actions are run via rake tasks. In development, when classes are autoloaded (i.e. only loaded when referenced), the rake tasks work fine. In production, however, the tasks fail because, in the context of a rake task,  ApiCheck.registry is empty. None of my classes were registered. This struck me as odd because in production Rails eager loads…

Continue reading Rails Production Eager Loading Ignored by Rake Tasks

Leave a Comment

First Post!

This blog is just getting started, so please give it some time. I hope to have content related to software development (Ruby, Ruby On Rails, React), devops (Docker, Linux), work, life, and play. I want this to be my corner of the internet where I can dump stuff I want to remember as well as give back to the open source and other online communities that I’ve borrowed from big time over the years. If that sounds good then follow me on Twitter, which I intend to start using, so you can stay tuned.

Continue reading First Post!

Leave a Comment