Blog of things

Deploying this site via docker

2024-8-30

By Sumit Kumar Maitra

This is a static website, that uses the a custom fork of the original Poet library to render markdown files as html. I wanted to learn about Docker and Kubernetes so I decided to host it on a container first before figuring out how to deploy it to Kubernetes. This series is going to be my experience of the process.

Development Environment

  • Debian on an amd64 machine

  • Gitlab
    RaspberryPi OS on a Pi4 with 8 Gb memory

  • Kubernetes Cluster
    1 Control Plane - Raspberry Pi4 with 8Gb memory 3 nodes - Raspberry Pi 5 with 8Gb memory each

Setting up Docker

One a clean system, I uninstalled the Docker packages that came with the OS and reinstalled it based on instructions from Docker

Quoting from from the above link

  1. Setup Docker's apt repo
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
  1. Install the latest Docker packages.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. Verify that the installation is successful by running the hello-world image:
 sudo docker run hello-world

Later on I figured out this installs the Docker Engine only? The difference? Well you have another component called Docker Desktop. That adds additional components to the CLI, primary amongst that is the init command. No harm done, I did not install Docker Desktop so I had to setup the docker files for this project manually.

Manually setting up your docker container

You need generally need three files to describe your container

Setting up Gitlab

docker login gitlab.piofthings.net:5050
docker build -t gitlab.piofthings.net:5050/sites/piofthings-web .
docker push gitlab.piofthings.net:5050/sites/piofthings-web

alt text

sudo gitlab-runner register \
  --url https://gitlab.piofthings.net \
  --token glrt-pgTaqVw8zasU_yN9wDK8 \
  --executor docker \
  --description "Docker in Docker Runner" \
  --docker-image "docker:27.1.1" \
  --docker-privileged \
  --docker-volumes "/certs/client"

Setup Docker in Docker

https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#use-docker-in-docker