Articles

New Website

Welcome to my new website. 👋🌍🖱️ This is a statically hosted website that replaces my previous one. The old website loaded content dynamically from various sources, and was made from scratch. Read about it in the old post. The source code is still available. To reduce hosting costs, I deleted my Kubernetes cluster which ran mostly obsolete projects and moved to a combination of Netlify for static sites, and a simple sub 10€ VPS on Greenhost.

Hosting Irssi in the Cloud

This post goes into the journey and reasons of why and how I am currently hosting the IRC client Irssi in my Kubernetes Cluster. Permanently Connected If you use IRC you know it is a badge of honor or rite of passage to have your nick always be online, and ideally also have access to the log of messages that happened while you were gone, as this is not the case by default in IRC, contrary to many new messaging platforms such as Discord.

How to Fix Empty Project in SonarQube Docker

This post shows one way to fix an issue that may cause a SonarQube project to show up as empty only when the scan is run in a container environment. TL;DR Concerning the issue: “This project is empty” in the SonarQube UI: SonarQube does not like being run as the root user. Specify a different user to be used in the container, and run the scan from this user’s home directory.

My Own Kubernetes Dashboard

I recently made my own dashboard displaying some information about my Kubernetes cluster. In this post I will gather some thoughts about the reasoning of why I built it, and some information about the technical details. The dashboard is currently deployed at k8s-dashboard.lolei.dev. Why - History I wanted to have a dashboard for my Kubernetes cluster, so I can see and monitor various information about the infrastructure at a glance, without having to have access to a terminal or the cloud provider interface.

How This Website Works

I have created this website as a way for me to play around with different technologies. It is not intended to be a masterpiece, especially on the UI design-end, but it has a few neat features you may be interested to read about. The following sections list some aspects of the website and its deployment. Frontend React.js and Next.js are used as web-frameworks (using TypeScript, of course). They may seem overkill for a website as simple as this one, but as it also handles dymanic content they are a good fit.

How to Fix Empty Project in SonarQube Docker

Planted September 28, 2021

This post shows one way to fix an issue that may cause a SonarQube project to show up as empty only when the scan is run in a container environment.

TL;DR

Concerning the issue: “This project is empty” in the SonarQube UI:
SonarQube does not like being run as the root user. Specify a different user to be used in the container, and run the scan from this user’s home directory.

A containerfile like this suffices:

FROM docker.io/openjdk:11
RUN useradd --create-home --shell /bin/bash sonarqube
USER sonarqube
WORKDIR /home/sonarqube

More Thorough Explanation

I’ve been setting up a few projects to be analyzed by SonarQube recently. A TypeScript project had its own issues that may be worth for a blog post, but in this Kotlin project this post is about I didn’t find any solutions online, so I’m making this post solely in hopes of shortening the journey for people who stumble upon the same issue. It isn’t super interesting, so if you’re not experiencing this issue yourself you may as well stop reading.

In this Kotlin Gradle project, I noticed that the project shows up as an empty project in the SonarQube UI, however only if the scan was triggered from within a container environment. I’ve used both the SonarScanner Gradle plugin and the CLI, both of which worked fine locally, but when using it from within a container it presented an empty project as a result. This led me on a wild goose chase of trying to find out the differences between the locally triggered scan and the one that’s started via CI / a container. (After even realizing that it’s not just the CI’s fault, but the container environment’s.) In the end, it turns out that SonarQube cannot handle not being run from a “normal” user environment. Most images use the root user by default, which does not count as such.

What makes it work is creating a non-root user and switching to that user’s home directory before executing the scan, of course with the code to be scanned in that directory, or a subdirectory, as well. For CI purposes, that can be a base image as listed in the TL;DR above (if it’s not a Java project the FROM directive may differ naturally), or even one that just includes a line such as this:

RUN useradd --create-home --uid 1000 --shell /bin/bash sonarqube

As long as the user and the home directory exists, and the CI provider facilities overwriting the default user with whom the pipeline steps are run, this is enough. On Bitbucket Pipelines, this can be done with the run-as-user step config option, which needs a UID of an existing user in the image. Since the pipeline may also clone the repo into some other directory, its contents may also need to be copied to the desired user’s home directory.

References

The only marginally related discussion about this I could find online is this one, which has Java user woes as well, but triggers a different kind of bug. For completeness' sake, many other potential solutions for the “This project is empty” problem can be found here.

Addendum

  • I hope my SEO is good enough so search engines will display this post for people with relevant interest.
  • I mentioned “Docker” in the title for this purpose, but it should be the same for any container engine/runtime. I tested it with Podman as well.