Oct 21, 2019

Using Ansible with GitHub Actions

My most recent work with GitHub Actions involves migrating Transverse from being deployed manually using Ansible run on my laptop to a CI/CD approach using Ansible on GitHub Actions. Now I can push changes and deploy from anywhere without requiring access to my personal laptop or the private keys to connect to my server.

Keep reading→

Oct 1, 2019

Stuff I Use

These are all of the things I use on a daily basis. Everything listed here is a high-quality product that I enjoy using and would recommend to others.

Keep reading→

Sep 9, 2019

Deploying projects to Cloud Run using GitHub Actions

Over the past month I made some small but significant changes to my notes app project called Contrast. It was always deployed as a Docker container on Google Cloud Run and that didn’t change, but the process of getting it there is now completely different. The build process now uses multi-stage Docker builds, is built using GitHub Actions workflows, and is deployed automatically on pushes.

Keep reading→

Jul 15, 2019

New project: Contrast Notes

I’m taking more notes at work these days. They’re mostly meeting notes and to-do lists. I was trying to figure out the best app for me to take notes the way I do. I didn’t like the Notes app on macOS or a text editor, so I decided to write my own Markdown notes app. It ended up being a great project idea!

I call it Contrast and it’s available here: https://contrast.site. I’m still working on the landing page. The code is on GitHub: https://github.com/Preetam/contrast. It uses Mithril.js, runs on Cloud Run (my first serverless app!), and I used Figma for the design.

It’s a very simple app. It runs entirely in the browser (no communication with the server) and uses local storage for saving. There’s no syncing. Instead, there is a “save” button you can use to save the Markdown contents of a note somewhere on your computer. I don’t need syncing or sharing support because these notes don’t last very long. Once I draft something and clean it up, I post it somewhere else like Slack or GitHub.

Besides actually using it to take notes, it’s also an exercise in designing something, building it, figuring out what doesn’t work in practice, and redesigning. The local saving and full rendered view features came after a few days of use and realizing they were something I really wanted. I’ll continue making small improvements over time, but I am still considering this project done.

Jul 14, 2019

Getting started with Cloud Run

Cloud Run is a service on Google Cloud that lets you run Docker Containers in a serverless way. Billing works a lot like AWS Lambda; you’re charged for CPU and memory in 100 ms increments. Unlike AWS Lambda, you can run any Docker image that listens on an HTTP port.

Here’s a really simple example with a Go program that runs a simple HTTP server:

package main

import (

func main() {
	http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "hello, world!\n")
	http.ListenAndServe(":"+os.Getenv("PORT"), nil)

Here’s the Dockerfile to package that program into a simple image:

FROM alpine
COPY hello-world /bin/hello-world
CMD hello-world

Cloud Run only seems to work with images hosted on Google Cloud Container Registry. If you only push to Docker Hub, you need to do a few more things to get your image ready for Cloud Run. Fortunately you can do the rest from the Google Cloud Shell in your browser.

You need to configure Docker in your Cloud Shell environment and then re-tag your image for GCR.

# Set up Docker
gcloud auth configure-docker

# Pull image from Docker Hub
docker pull preetamjinka/golang-hello-world

# Re-tag image for Google Cloud Container Registry
docker tag preetamjinka/golang-hello-world gcr.io/my-project-180915/golang-hello-world

# Push
docker push gcr.io/my-project-180915/golang-hello-world

Once that’s done, you can create your Cloud Run service with just a few clicks and have a serverless website up and running.

Jun 14, 2019

New styling

I spent a few evenings this week redesigning this site. I usually update the HTML and CSS locally and tweak things as I go, but this time I started with a mockup in Sketch and didn’t touch the code until I had something that really looked good. This workflow worked out great.

Here’s what changed:

  • Font styling has been adjusted to look cleaner and more consistent. I thought about changing the font I used but small color and size tweaks ended up solving the issues.
  • There are summaries of posts on the front page instead of lists. Smaller posts like this one show up as a whole.
  • The top posts have moved to their own section.
  • Comments have been removed.

Now I just have to write more 🙂.