Now Reading
Why I created the PAKman Construct System

Why I created the PAKman Construct System

2023-05-16 09:23:40

PAKman is likely one of the 4 core modules that energy instellar.app (opens in a new tab). It is open-sourced (opens in a new tab) and builds your utility utilizing github actions into alpine packages that get delivered to an S3 appropriate bucket you specify by way of instellar. Our platform then takes that constructed package deal and deploys the applying in your infrastructure.

basic workflow

At first

Back in 2018 I looked at using docker before I embarked on the journey to build my own build system. At that point I had been using docker for a long time. I was an early user of docker and one of the issues I constantly ran into was the following:

  • Large build artifact (hundreds of MB)
  • Needed a Registry
  • Consumes bandwidth
  • Slow deployments

At first I considered just using docker because it was the ‘standard’. Everyone was using docker and docker swarm was in it’s hey days, k8s was gaining steam. Most of the docker images were built using ubuntu as the base image, as you can imagine the built images were quite large. Alpine linux was gaining popularity and was starting to be used in the docker community to reduce image size. I often wondered, why the community didn’t just build using alpine’s native build system. So I tried it for myself. It took me a long time to work through the alpine build system, the documentation was scarce and I had to trial and error my way to understanding it. My little experiment made me realize that while the final output was amazing (built packages were ranging from few MB – 50MB depending on the application) it was extremely complex to use. I figured most people probably just ended up using docker due to simplicity and readily available documentation.

I ended up mastering building with alpine’s package system and threw together some scripts that would automate and make things easy to build with alpine packages. There was however one problem, this meant not using docker for running the applications. With docker you build the app into a docker image and you run the entire image. You wouldn’t just install the custom package in a docker container because that means the image would need a package manager and that would just make the final image even larger. This is where the concept of docker being an ‘application’ container hit hard.

I also explored kubernetes to see what it could do and figured that kubernetes was way too complex for most deployments. The conclusion I came to was k8s and docker would work together. If I wanted to use my alpine package build method I would need something else.

Enter LXD

While doing my research I found LXD, it advertised itself as being a ‘system’ container this meant creating an LXC container would mean I had the entire OS running including the package manager. This was exactly what I was looking for and would fit with my build system like peas in a pod. LXD containers meant that all I had to do was expose the alpine package in a file system and add it as the repository inside the alpine linux container and I could run apk update && apk add [package] and be done with it. I hacked together a proof of concept with bash and terraform and amazingly it worked! I was actually able to just build my app and just ship my app to my lxc container and it was blazingly fast! Apps were being deployed in a matter of a few seconds! Upgrades were also handled by alpine packages by adding the -u flag. Upgrades were even faster than installing a fresh package.

docker vs pakman

A new Invention is needed!

While my proof of concept worked it was far from ready for primetime. I needed something which is robust, written in a language I’m familiar with (elixir), and most importantly worked with an existing infrastructure I didn’t have to host. The first versions of PAKman I hacked together was a combination of building packer images using bash script that would run in a custom gitlab runner. While it worked, it was not elegant and was not flexible. In 2018 Github Action was released I explored github actions and realized that I could create my own custom action inside a docker container which meant I could use whatever programming language I wanted to create the build system.

I realized that I needed to create a simple solution for people and simply telling everyone to simply ‘just use alpine’s build system’ would not work. I had an idea that I could essentially simplify everything down to a .yml file. I needed to develop an intermediary layer that would take the yaml file and convert it into files that the apkbuild system for alpine linux would understand. This is the birth of PAKman

what pakman does

Project Goal

While I still needed to use a docker container to create the final build since that’s how github actions work. I realized that I can simply extract the artifact and ship it to an S3 compatible storage. This was the most simple design. Since once the package was built I could install and run it anywhere Alpine Linux ran. This would achieve the following goals:

  • No need for custom infrastructure for building
  • Packages need to be as small as possible
  • Save on bandwidth costs
  • Fast deployments (matter of seconds)

ship small packages

See Also

While many may challenge my decisions of saving bandwidth. I do have my reasons. I believe if something can be done well it should be done. In the big picture the goals of PAKman serves our mission for instellar.app (opens in a new tab). Instellar allows anybody to run their very own PaaS on their very own infrastructure. This implies it is essential for us to maintain the price of possession low. If we will save on bandwidth prices for our prospects it is our responsibility to do it. One other beneficial asset we save is time. Small packages imply deployments are quick! The replace for the weblog you might be studying now was deployed in 6 seconds! You may see PAKman in action (opens in a new tab).

fast deployments

The ultimate constructed artifact that will get shipped over the wire for this NextJS weblog weighs in at 5.69 MB

built artifact

Welcome to the long run!

© Zack Siri.RSS

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top