I’ve done a few rounds of 100 Days of Code in the past, but never really made it past 2 weeks. Part of the reason for that failure is the weekend portion - I don’t like to computer on the weekend since I computer very hard during the week.

I decided it would be a really good use of my time to work on my Indoor Air Quality platform as a part of my attempt at 100 Days of Code. It’s the next step for me in my career, so I need a way to force my effort.

There are two parts to making my IAQ platform successful, the sensors themselves, and the backend system.

Previous Days

  • Day 1 - Getting the infrastructure setup for development
  • Day 2 - Getting basic data out of Temp/Hum sensor, figuring out scope for others
  • Day 3 - Publish data to InfluxDB
  • Day 4 - Handled some errors in the publisher, got CouchDB up adn running
  • Day 5 - Slack bot alerts!
  • Day 6 - Health Checks babay!
  • Day 7 - Ansible and other things for a friend’s project
  • Vacation - I’m on vacation so haven’t been coding much

Day 8

Today I worked on setting up a Makefile to test, build, push multiple docker containers to Github registry. The tests will be run to lint the code I’ve written, then build each container by cd‘ing into each subfolder, then push each tagged image to the registry. From here I want to build out a testing suite that runs on commit, using Github Actions. The idea would be, I push code to the repo, GH Actions runs the Makefile, where the test, build, push, occurs - then is followed by a test deployment which gets tested for application level items. Should be a nice way for me to test things without having to deal with manually copying files everywhere. Anyways, below you’ll find the Makefile as I’ve written it.

# Variables
DOCKER_TAG := $(shell date +%Y-%m-%d)
# Docker Repo Info

help:
	@echo "Makefile for IAQ-ONE-sensors"
	@echo ""
	@echo "Commands:"
	@echo "test - Run all tests and linting"
	@echo "build - Build containers locally, tagged with $(DOCKER_TAG)"
	@echo "push - Push containers to registry, tagged with $(DOCKER_TAG)"
	@echo "all - Test, Build, then Push containers to registry"


.DEFAULT_GOAL := all

test:
	@echo "Testing how bad your coding is for the formaldehyde container"
	cd formaldehyde && \
	docker run --rm -i hadolint/hadolint < Dockerfile
	@echo "Testing how bad your coding is for the multigas container"
	cd multigas && \
	docker run --rm -i hadolint/hadolint < Dockerfile
	@echo "Testing how bad your coding is for the particulate container"
	cd particulate && \
	docker run --rm -i hadolint/hadolint < Dockerfile
	@echo "Testing how bad your coding is for publisher container"
	cd publisher && \
	docker run --rm -i hadolint/hadolint < Dockerfile
	@echo "Testing how bad your coding is for temperature container"
	cd temperature && \
	docker run --rm -i hadolint/hadolint < Dockerfile

build:
	test
	@echo "Building formaldehyde container"
	cd formaldehyde && \
	docker build -t ghcr.io/wesdottoday/iaq-one-formaldehyde:$(DOCKER_TAG) -t ghcr.io/wesdottoday/iaq-one-formaldehyde:latest .
	@echo "Building multigas container"
	cd multigas && \
	docker build -t ghcr.io/wesdottoday/iaq-one-multigas:$(DOCKER_TAG) -t ghcr.io/wesdottoday/iaq-one-multigas:latest .
	@echo "Building particulate container"
	cd particulate && \
	docker build -t ghcr.io/wesdottoday/iaq-one-particulate:$(DOCKER_TAG) -t ghcr.io/wesdottoday/iaq-one-particulate:latest .
	@echo "Building publisher container"
	cd publisher && \
	docker build -t ghcr.io/wesdottoday/iaq-one-publisher:$(DOCKER_TAG) -t ghcr.io/wesdottoday/iaq-one-publisher:latest .
	@echo "Building temperature container"
	cd temperature && \
	docker build -t ghcr.io/wesdottoday/iaq-one-temperature:$(DOCKER_TAG) -t ghcr.io/wesdottoday/iaq-one-temperature:latest .

push:
	@echo "Pushing formaldehyde containers"
	cd formaldehyde && \
	docker push ghcr.io/wesdottoday/iaq-one-formaldehyde:$(DOCKER_TAG) && \
	docker push ghcr.io/wesdottoday/iaq-one-formaldehyde:latest
	@echo "Pushing multigas containers"
	cd multigas && \
	docker push ghcr.io/wesdottoday/iaq-one-multigas:$(DOCKER_TAG) && \
	docker push ghcr.io/wesdottoday/iaq-one-multigas:latest
	@echo "Pushing particulate containers"
	cd particulate && \
	docker push ghcr.io/wesdottoday/iaq-one-particulate:$(DOCKER_TAG) && \
	docker push ghcr.io/wesdottoday/iaq-one-particulate:latest
	@echo "Pushing publisher containers"
	cd publisher && \
	docker push ghcr.io/wesdottoday/iaq-one-publisher:$(DOCKER_TAG) && \
	docker push ghcr.io/wesdottoday/iaq-one-publisher:latest
	@echo "Pushing temperature containers"
	cd temperature && \
	docker push ghcr.io/wesdottoday/iaq-one-temperature:$(DOCKER_TAG) && \
	docker push ghcr.io/wesdottoday/iaq-one-temperature:latest

all: test build push