Deploying sites with Gogs and Traefik

What is Gogs?

Gogs is a super easy to setup and lightweight Gitlab alternative. It has a sleek and nice looking UI, amazing UX, and can be customized however you want. It also supports being run on pretty any platform including Linux, Mac OS X, Windows and ARM.

Ok how about Træfik

Træfik (pronounced like traffic) is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. It supports several backends which includes Docker, Kubernetes, and Amazon ECS to manage its configuration automatically and dynamically.

The plan

I have been wanting to move my blog to be hosted on my server, but I didn’t know how to do it with my current infrastructure. I wanted the site to be a mirror of my Gogs repo. To set this up would required some work because Gogs is run in its own container and the NGINX server to host my site would be in another. So I started looking around then remembered. I store my Gogs data in a folder on my host machine (/var/gogs). This meant that I could run a git checkout on post-receive on my Gogs docker. This would create a folder at /var/gogs/serve/hampton.pw. Next I mounted that folder on the docker-nginx docker container at /var/www. This then would allow for my site to be auto deployed.

Code

The post-receive I used was “git –work-tree=/data/serve/hampton.pw/ –git-dir=/data/git/gogs-repositories/herohamp/hampton.pw.git checkout -f” this is run inside my Gogs docker image. Now I started working on docker-compose file. It ended up looking like this.

the Traefik labels allows for Traefik to automatically deploy the site for me with https.

Conclusion

While this does required more work to get setup than github pages, it also supports building and serving php files.

Ai Recolors New Mexico State Flag

Before reading this try it out here: /tools/new-mexico-ai

Intro

I’m bad at design, but good at programming. Which means I am very good at design. If your first response to that was “That makes no sense, you just said you are bad” then you are kinda correct. The results were next level, but they were pretty good.

Backstory

I was looking at state flags one day and came to the realization that the New Mexico flag one of the only good looking flags. I only had one issue with it, the coloring. I don’t know what about it I did not like, but I just knew I did not particularly like the color scheme. After a bit of time, I had an idea. Since I don’t know what I like, why not have a computer do it for me.

How?

It is super simple. First, it generates 2 random colors, then it using some JavaScript Magic renders it onto the user’s screen. Then the user has four choices, Love it, Like it, Meh, and Hate it. It then feeds the Neural Network a value, 1 for Love it all the way to 0 for Hate it. It uses this in the future to find the perfect color scheme. The user then continues to do this for as long as they wish. Once they think it has been long enough it gets tired, then click the dandy “Generate” button. That runs 200 thousand rounds of generating random colors, sending it to the trained and personalized neural network, and save it to an array. After all the simulations finish, it then finds the color scheme with the higher score and displays it to the user.