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-apilistens on port 4000 (it was 2300):http://lighthouse-api:4000on thesparknetwork. 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 thesparknetwork with no port published. It reads the database aslighthouse_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,stoppedornot_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) andGET /v1/releases. Every request butGET /healthzneeds a bearer token,SHARED_LIGHTHOUSE_VISTA_TOKEN. A wrong parameter is a400that names it. lighthouse health apiislighthouse-api’s healthcheck.
changed
- Lighthouse’s compose file takes secrets:
LIGHTHOUSE_DATABASE_READER_URLandSHARED_LIGHTHOUSE_VISTA_TOKEN, forlighthouse-apionly, 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
lighthouseservice by hand, thendeploy lighthousefrom its prompt startslighthouse-apiwith 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, asdeploytakes one.checkbefore 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 withCAP_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.jsonmust name itsservice, 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 inmount:/proc/1/net/dev:ro. A read-write mount under a read-only exception is refused with a hint.:roon a socket is refused whenpolicy.jsonloads, since a socket mounted read-only still takes every request. - The migrator’s database URL is
LIGHTHOUSE_DATABASE_MIGRATOR_URL(it wasLIGHTHOUSE_MIGRATOR_DATABASE_URL), so the three connection strings readLIGHTHOUSE_DATABASE_URL,LIGHTHOUSE_DATABASE_MIGRATOR_URLandLIGHTHOUSE_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_URLsetspool_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 lighthouseis JSON: one record per line, throughblackboxlog.LOG_FORMAT=textorAPP_ENV=devgives readable lines,LOG_LEVELsets the level, and a local run with the CLI stays readable. Each deploy step’s output is unchanged, as plain[<project> <step>]lines.ERRORnow means someone should look: a failed check or deploy that’s tried again by itself isWARN, a project marked broken isERRORinstead ofWARN, and a self-update that failed isERRORinstead ofINFO.- A startup failure is an
ERRORrecord:Lighthouse can't run, with the reason inerr, so it shows up in a search by level. It used to be a plainlighthouse: …line. - One failure, one line: a failed deploy is no longer logged again as a failed check and a failed scan.
- Standard fields:
componentsays which part of Lighthouse wrote a line,deploy finishedanddeploy failedcarryoutcomeandduration_ms, andmigration appliedhasduration_msinstead oftook. 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 setupfollows the standard: it recommends deploying from version tags, says to push a baseline tag before moving a running project over, and shows thecom.mobasity.public-urllabel.
fixed
- Labels written as a list:
- key=valuestopped a deploy withcannot unmarshal array. A list now works like a map, and the public-address label is checked the same way in both. helpwith a wrong argument leftrulesout 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.
More to look at
all projects-
My own little vault for the passwords, keys, and secrets my projects need.
-
One consistent way for my Go projects to communicate with Cove.
-
One place to find out what my server's containers have been saying.