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…
16 CommentsChris Stump Online Posts
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…
Leave a CommentThe 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:
1 2 3 4 5 6 7 8 9 |
class Vehicle def manufacture(n) n.times { create } end def create raise NotImplementedError, "subclass did not define #create" end end |
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…
3 CommentsI 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…
22 CommentsIf 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…
Leave a CommentYesterday 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…
10 CommentsA 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…
105 CommentsI 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:
1 2 3 4 5 6 |
[10] pry(main)> record = ActiveRecordSubclass.new => #<ActiveRecordSubclass:0x00555d2e588a28 ... > [11] pry(main)> record.id = "09378476376282" => "09378476376282" [12] pry(main)> record.id => 9378476376282 |
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…
Leave a CommentI got bit by the Rails production environment today. Here’s the scenario: I have a set of classes that all mixin the same module.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
module Syncable ... end class DownloadCars include Syncable ... end class DownloadTrucks include Syncable ... end |
Upon include the module “registers” the class with another class
1 2 3 4 5 6 7 8 |
module Syncable extend ActiveSupport::Concern included do |base| ApiCheck.registry[base.api_url] = base end ... end |
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…
2 CommentsThis 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.
Leave a Comment