Strapi, a great data manager for static websites

Strapi is an open-source content management system (CMS) that lets developers, and even less technical folks, easily create and manage data for websites and apps. It provides a friendly UI for modelling your data structure, along with an API to access that same data. Strapi can be deployed locally with Node.js, in the cloud, or on Kubernetes. With Strapi, you can focus on creating content without getting bogged down in the complex, repetitive technical work of building a CMS from scratch.

11ty, a generator that gets out of your way

You can compare 11ty to Jekyll, Gatsby, or Hugo; that said, it stands out from other popular static site generators by giving you a ton of flexibility in how you organize your data. On top of that, it supports a wide range of template engines, including Markdown, Nunjucks, HTML, and even plain JavaScript. 11ty doesn't force any rigid folder structure on you, yet still provides sensible defaults that keep builds fast and development lighter and more flexible than its competitors.

A Strapi plugin to deploy with GitLab in one click

To trigger deployments straight from Strapi, I built a small plugin that calls the API from Gitlab to kick off a pipeline that deploys to Google Cloud Firebase Hosting. All it takes is following a tutorial on Strapi's website and tweaking it to your liking. Note that you'll need to get comfortable with React.

Here is that plugin in all its glory:

Interface du plugin GitLab pour Strapi

Self-hosting Strapi at home on Kubernetes

I like running open-source software at home in my homelab. I run my virtual machines on Proxmox, which lets me host a bunch of services without spending much.

I also tend to default to running my apps on Kubernetes whenever it makes life simpler. That's definitely true for Strapi. For anyone who'd like to run Strapi on Kubernetes, here is the main YAML file that makes it happen. Notice the initContainer command, which checks whether the site folder already exists and, if not, initializes Strapi automatically, all using the stock Node.js image.

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
  name:  strapi-fbcom-cms
  namespace: strapi
  labels:
    app:  strapi-fbcom-cms
spec:
  selector:
    matchLabels:
      app: strapi-fbcom-cms
  replicas: 1
  template:
    metadata:
      labels:
        app:  strapi-fbcom-cms
    spec:
      initContainers:
        - name: strapi-fbcom-install
          image: node:16.13.2
          imagePullPolicy: IfNotPresent
          command: ["/bin/sh", "-c"]
          args: ["[ -d fbcom ] || yarn create strapi-app fbcom --quickstart --no-run"]
          workingDir: "/app"
          volumeMounts:
          - name: strapi-pv-cms
            mountPath: "/app"
      containers:
      - name: strapi-fbcom-cms
        image:  node:16.13.2
        imagePullPolicy: IfNotPresent
        command: ["yarn"]
        args: ["strapi", "develop"]
        workingDir: /app/fbcom
        resources:
          limits:
            cpu: 1000m
            memory: 4Gi
          requests:
            cpu: 250m
            memory: 1Gi
        env:
        - name: STRAPI_DISABLE_UPDATE_NOTIFICATION
          value: "true"
        - name: STRAPI_TELEMETRY_DISABLED
          value: "true"
        ports:
        - containerPort:  1337
          name:  http
        volumeMounts:
        - name: strapi-pv-cms
          mountPath: /app
        - name: "strapi-config-fbcom"
          mountPath: "/app/fbcom/config/server.js"
          subPath: "server.js"          
        - name: "strapi-config-fbcom"
          mountPath: "/app/fbcom/config/plugins.js"
          subPath: "plugins.js"          
      volumes:
        - name: strapi-pv-cms
          persistentVolumeClaim:
            claimName: strapi-pv-cms-claim
        - name: "strapi-config-fbcom"
          configMap:
            name: "strapi-config-fbcom"
      restartPolicy: Always

Obviously, the full setup is a tad more involved; here is the layout of the Kubernetes YAML files:

Plain text
strapi/
├── 00-namespace.yml                 # Creation du namespace
├── 01-cms-volume.yml                # Volume pour le CMS
├── 02-deployment-fbcom.yml          # Deployment de Strapi (initContainer+pod)
├── 03-ingress.yml                   # Strapi endpoint + cert-manager
├── 04-service.yml                   # Exposition de Strapi pour le Ingress
├── 05-configs.yml                   # Fichiers de configuration pour Strapi et Nginx
├── 06-gitlab-sa.yml                 # Acces Gitlab pour lire/écrire les fichiers
├── 07-static-volume.yml             # Volume pour site web statique (staging)
├── 08-static-deployment-nginx.yml   # Deployment du site staging
├── 09-static-ingress.yml            # Web static endpoint
└── 10-static-service.yml            # Exposition de nginx

0 directories, 11 files

Focused on no-nonsense editing

At the end of the day, two of the most important things in any architecture are efficiency and simplicity. Using powerful, free, open-source software means we don't have to reinvent the wheel... we can just play Lego, snapping pieces together so we can focus on the final result.

Strapi and 11ty let me put together a setup where I can add articles and tweak my website's text and images super quickly and effortlessly.

Thank you, open source!