Lighthouse

live · 1.6.1internal

I push code to GitHub, and my server takes it from there.

What it is

Lighthouse is a self-hosted deployment system that watches my GitHub repositories and automatically builds and deploys updates to my server.

It’s what lets me push code from my computer and have it running on my server without having to do anything else.

Why I made it

I wanted to understand how deployment systems actually work, and I didn’t want to depend on an external service to deploy my projects for me.

I’ve always wanted my server to be as self-sufficient as possible. I wanted to own the infrastructure behind everything I was building, including the process that gets my code from my computer to the server.

More than anything, I wanted to be able to work on a project, push my changes to GitHub, and have them running without needing to connect to the server and update everything manually.

I didn’t want deploying something to be a separate task.

So I decided to build my own system to handle it.

How it works

Lighthouse watches the GitHub repositories I’ve connected to it. When it detects a new commit on a project’s deployment branch, it downloads the updated code, builds the Docker containers, and deploys them to my server.

It also handles things like running tests, checking whether a deployment is healthy, and rolling back when something goes wrong.

When a project needs credentials or API keys, Lighthouse gets them from Cove, another service I built, and provides them during deployment.

The two work together so I don’t have to manually manage every update or keep sensitive information in my repositories.

Most of the time, all I need to do is push to main and let Lighthouse handle the rest.

Where it’s at

Lighthouse is running on my server and handles deployments for my projects.

It’s reached the point where I can spend most of my time developing locally, push my changes, and let the server take care of updating itself.

There’s still plenty I want to improve, particularly around making the server more self-sufficient and resilient.

But the original goal is working: I can focus on building things instead of manually deploying them.

Changelog

1.6.1latest1 change

changed

  • lighthouse-api listens on port 4000 (it was 2300): http://lighthouse-api:4000 on the spark network. A consumer’s address changes with it.
1.6.03 new · 2 changes

added

  • lighthouse-api: the same image run as /lighthouse api, on port 2300 of the spark network with no port published. It reads the database as lighthouse_reader, which can’t change anything, with at most 4 connections, and holds no Docker socket, control socket or Cove token. It runs as user 10001 with a read-only filesystem, no capabilities and a 64 MB memory limit.
  • Its answers: GET /v1/projects (every project and its state: ok, failing, broken, stopped or not_deployed), GET /v1/deployments (a time range, newest first, a page at a time), GET /v1/deployments/{id} (one deploy with its steps and their output, secrets already hidden) and GET /v1/releases. Every request but GET /healthz needs a bearer token, SHARED_LIGHTHOUSE_VISTA_TOKEN. A wrong parameter is a 400 that names it.
  • lighthouse health api is lighthouse-api’s healthcheck.

changed

  • Lighthouse’s compose file takes secrets: LIGHTHOUSE_DATABASE_READER_URL and SHARED_LIGHTHOUSE_VISTA_TOKEN, for lighthouse-api only, fetched from Cove by the deploy and handed to the update helper as v1.5.0 does. Create the token in Cove before deploying this version (generate SHARED_LIGHTHOUSE_VISTA_TOKEN 64). It needs v1.5.0 or newer running: an older Lighthouse can’t hand secrets to its update helper.
  • A first install starts only the lighthouse service by hand, then deploy lighthouse from its prompt starts lighthouse-api with its secrets (README, “Start Lighthouse”).
1.5.04 new · 2 fixes · 7 changes

added

  • Lighthouse’s own update carries secrets: the ${KEY}s of Lighthouse’s compose file are fetched from Cove as for any project and handed to the update helper in its environment, never on disk; the hand-off file names them only. The helper also gets the previous version’s, so a rollback starts that version with its own. If those can’t be fetched, the update waits and is tried again. After a successful update the helper’s container is removed, so it doesn’t keep the values.
  • check <name> <tag or commit> checks that release or commit, as deploy takes one.
  • check before the first release: a project that deploys releases but has no version tag yet is checked at its newest commit, with a note saying so, instead of answering “has no releases yet”.
  • policy.json: Sonar’s gateway (sonar-proxy) may mount the data folders read-only with CAP_DAC_READ_SEARCH, to size each project’s folder, and Sonar’s agent may read the host’s network counters, the one file /proc/1/net/dev, read-only.

changed

  • An exception covers one service: every exception in policy.json must name its service, so a service added to a project later gets nothing by accident. A finding that belongs to the whole project, such as another project’s network, can’t be allowed.
  • A host mount says how it may be mounted: an allowed mount ends in :ro (read-only only) or :rw (either way), and a finding’s ID carries the mount’s mode, as in mount:/proc/1/net/dev:ro. A read-write mount under a read-only exception is refused with a hint. :ro on a socket is refused when policy.json loads, since a socket mounted read-only still takes every request.
  • The migrator’s database URL is LIGHTHOUSE_DATABASE_MIGRATOR_URL (it was LIGHTHOUSE_MIGRATOR_DATABASE_URL), so the three connection strings read LIGHTHOUSE_DATABASE_URL, LIGHTHOUSE_DATABASE_MIGRATOR_URL and LIGHTHOUSE_DATABASE_READER_URL. Create the new key in Cove before deploying this version.
  • The README covers setup: the server, the database, Cove, adding a project and the rules it follows, publishing Releases, and configuration. The project is published under the MIT license.
  • A confirmation shows the environment: questions such as remove’s read ? (prod) Stop watching "plop", and stop and remove its containers? (y/N), with (prod) in red, since the question replaces the prompt that showed it.
  • At most 10 database connections: Lighthouse’s pool is capped at 10, unless LIGHTHOUSE_DATABASE_URL sets pool_max_conns. It used to open one per CPU, at least 4, on a Postgres server every project shares.
  • Go 1.27.4: picks up the standard library’s security fixes.

fixed

  • An unreadable self-update folder no longer lets deploys through: if Lighthouse can’t read its update helper’s hand-off files, it can’t tell whether the helper is mid-swap, so deploys now wait and a warning is logged, where they used to go ahead. A deploy that can’t list its old deploy folders says so in its output instead of skipping the cleanup silently.
  • A deploy by hand of a stopped project ran twice: a check that started while the deploy was in progress waited for its turn, then deployed the same commit again. It now sees the commit is already running and leaves it.
1.4.02 fixes · 7 changes

changed

  • docker logs lighthouse is JSON: one record per line, through blackboxlog. LOG_FORMAT=text or APP_ENV=dev gives readable lines, LOG_LEVEL sets the level, and a local run with the CLI stays readable. Each deploy step’s output is unchanged, as plain [<project> <step>] lines.
  • ERROR now means someone should look: a failed check or deploy that’s tried again by itself is WARN, a project marked broken is ERROR instead of WARN, and a self-update that failed is ERROR instead of INFO.
  • A startup failure is an ERROR record: Lighthouse can't run, with the reason in err, so it shows up in a search by level. It used to be a plain lighthouse: … line.
  • One failure, one line: a failed deploy is no longer logged again as a failed check and a failed scan.
  • Standard fields: component says which part of Lighthouse wrote a line, deploy finished and deploy failed carry outcome and duration_ms, and migration applied has duration_ms instead of took. Lines no longer carry Lighthouse’s own version, environment or compose project, which Blackbox reads from Docker, and the GitHub token’s length is gone.
  • Go 1.27.3: picks up the standard library’s security fixes.
  • help setup follows the standard: it recommends deploying from version tags, says to push a baseline tag before moving a running project over, and shows the com.mobasity.public-url label.

fixed

  • Labels written as a list: - key=value stopped a deploy with cannot unmarshal array. A list now works like a map, and the public-address label is checked the same way in both.
  • help with a wrong argument left rules out of its usage line.
1.3.11 new

added

  • Blackbox can be deployed: the deploy rules refuse any project that mounts the Docker socket, and Blackbox needs it to read container logs. An exception now allows it for blackbox-proxy, the one service that has no network and only makes fixed, read-only requests. Blackbox’s other services are still refused.

all releases on GitHub

More to look at

all projects
  • Cove

    live · 1.0.4internal

    My own little vault for the passwords, keys, and secrets my projects need.

  • CoveClient

    live · 1.0.0Go library

    One consistent way for my Go projects to communicate with Cove.

  • Blackbox

    live · 0.0.2internal

    One place to find out what my server's containers have been saying.