Docs / Installation

Installation

GoPress can be started directly from source during development. In production, it is normally built as a Go binary and run with PostgreSQL, with Redis enabled only when L2 cache is needed.

Requirements

  • Go 1.25 or newer.
  • PostgreSQL 14 or newer.
  • Redis is optional.
  • cwebp is optional and only required for WebP media variants.

The gopress CLI

GoPress ships with a small orchestrator binary called gopress that wraps the server entry point. It auto-discovers themes and plugins on every start, so you never edit cmd/server/main.go by hand when adding extensions.

A directory under themes/ or plugins/ is picked up when it contains both:

  • a marker file at its root: theme.toml for themes, plugin.toml for plugins
  • at least one non-test .go file at its root

The CLI exposes three subcommands:

Command What it does
gopress serve [flags...] Regenerate the autoload package, then run the server. Any flag is forwarded to cmd/server (e.g. -config, -seed, or -theme-package to preview a theme package locally). Signals are forwarded to the child process for graceful shutdown.
gopress build [-o path] Regenerate the autoload package, then go build a single server binary. Default output is build/gopress-server.
gopress pkg keygen | check | build | digest | sign | verify | catalog Create Ed25519 signing keys; check a theme package and pack a theme directory into a reproducible .zip (see Theme Packages); print a package's content digest; sign or verify an extension package directory or .zip archive; sign or verify a market catalog (catalog sign | verify). Works outside a GoPress checkout.
gopress gen Regenerate the autoload package only β€” useful in IDEs or CI hooks.

Clone and Run

The fastest path to a running GoPress is a local make gopress build β€” no global install needed for a first look.

git clone https://github.com/0xmattg/go-press.git
cd go-press
go mod download

# Build the gopress CLI into ./build/ (no global install).
make gopress

# Start the server. First run opens the web installer.
./build/gopress serve

If you plan to use GoPress regularly, install the CLI onto your $PATH so you can drop the ./build/ prefix:

make install            # installs gopress to $GOBIN (or $GOPATH/bin)
gopress serve           # works from any directory after install

make install prints the export PATH=... line to add if $GOBIN is not on $PATH yet.

Open http://localhost:8080/install on first run. The installer verifies the PostgreSQL connection, writes the site configuration, initializes tables, creates the administrator account, and switches the current process to the live site after setup.

After installation:

URL Purpose
http://localhost:8080 Public site.
http://localhost:8080/admin CMS admin.
http://localhost:8080/swagger/index.html Interactive API documentation.
http://localhost:8080/api/v1/content Generic public content API.

Build a Production Binary

./build/gopress build                  # -> build/gopress-server
./build/gopress build -o ./myserver    # custom output path
./build/gopress-server

(Drop the ./build/ prefix if you ran make install.)

gopress build regenerates internal/autoload/autoload_gen.go first, then runs go build ./cmd/server. The resulting binary has the currently-present themes and plugins baked in at compile time β€” production deployments do not need the Go toolchain to "discover" anything at runtime.

The service discovers site configuration from sites/{host}/config.toml. For local development the default host is usually localhost.

Building on Low-Memory Machines

go build compiles packages in parallel across GOMAXPROCS cores, and each compile worker holds a sizeable working set in memory. On a 1 CPU / 1 GB VM (typical small VPS), parallel compilation can be killed by the OOM killer or fail with signal: killed.

If you hit this, force go build to compile one package at a time using GOFLAGS. The Go toolchain reads this environment variable transparently, so it applies to every step in the chain β€” make gopress, gopress serve, gopress build, and direct go build invocations:

GOFLAGS="-p=1"    make gopress              # serial compile of the CLI itself
GOFLAGS="-p=1"    ./build/gopress build     # serial compile of the server
GOFLAGS="-p=1"    ./build/gopress serve     # serial compile, then run
GOFLAGS="-p=1 -v" ./build/gopress build     # add -v to print package names as progress

Equivalent without gopress, after running ./build/gopress gen to refresh autoload:

go build -p 1 -v -o build/gopress-server ./cmd/server

-p 1 caps parallelism at one package; -v prints each package as it is compiled so the build does not look frozen. Expect a longer build time in exchange for a much lower memory peak.

First-run Installer

The web installer uses a two-screen flow followed by a completion phase:

  1. Database connection and table prefix.
  2. Site name, default theme, admin account, and interface language.
  3. Configuration write, migrations, seed data, and live-site switch.

The generated sites/<host>/config.toml is written with 0600 permissions and includes a unique, randomly generated jwt_secret; you never set it by hand.

If the target database does not exist, GoPress attempts to connect to postgres or template1 with the same account and create it automatically.

Keep the Installer Private

Until the installer finishes, it has no login: whoever reaches /install first can complete it. They pick the database (possibly their own), write config.toml, and create the first administrator. New HTTPS certificates are published in Certificate Transparency logs, and scanners probe newly certified domains for unfinished installers within minutes. Never let an unfinished installer be reachable from the internet.

Create the site config before the first start, so the installer does not listen on its default 0.0.0.0:8080, and turn on the install token:

[server]
host = "127.0.0.1"   # only the reverse proxy or an SSH tunnel can reach it
port = 8081

[install]
completed = false
require_token = true # off by default

The installer pre-fills the database form from any [pg] values in this file. With require_token = true its first screen asks for a one-time token that only someone with access to the server can see:

# printed when the installer starts …
journalctl -u gopress-example | grep "install_token"
# … and saved next to the config (0600), removed after installation
sudo cat sites/example.com/install-token

The token stops strangers from completing the installer, but /install is still reachable and answers. To keep it out of sight as well, also use one of the following, strongest first:

  1. SSH tunnel. Do not publish the site in the reverse proxy yet. From your computer run ssh -L 18081:127.0.0.1:8081 user@server, open http://127.0.0.1:18081/install, and finish the installer. Publish the site afterwards, and sign in to the admin through its real HTTPS address.

  2. Allow only your IP. In the reverse proxy, restrict /install until you are done:

    location ^~ /install {
        allow 203.0.113.10;   # your public IP
        deny all;
        proxy_pass http://127.0.0.1:8081;
    }
    
  3. Secret path that sets a cookie. Useful when your IP changes. A random path sets a short-lived cookie, and /install answers 404 without it:

    # Temporary: remove after installing. Generate both values with `openssl rand -hex 24`.
    location = /<secret-path> {
        add_header Set-Cookie "gp_install_gate=<token>; Path=/install; Max-Age=3600; Secure; HttpOnly; SameSite=Lax" always;
        add_header Cache-Control "no-store" always;
        return 302 /install;
    }
    location ^~ /install {
        if ($cookie_gp_install_gate != "<token>") { return 404; }
        proxy_pass http://127.0.0.1:8081;
    }
    

    Rewriting a secret path straight to /install is not enough. The installer's forms and redirects go to /install/... directly, so those URLs must be protected as well.

After installation /install returns 404 and the live site takes over. Keeping the proxy restriction for /install costs nothing. If you find a site you did not install, stop the process, delete its config.toml, and check the database it was pointed at before installing again.

Make Targets

Target Purpose
make help List all available targets (also runs when you type make with no args, or with an unknown target).
make gopress Build the gopress CLI to build/gopress.
make server Build the server binary via gopress build.
make gen Regenerate internal/autoload only.
make install go install ./cmd/gopress (puts gopress into $GOBIN).
make uninstall Remove the installed gopress binary.
make clean Remove the build/ directory.
make test Run all Go tests (go test ./...).
make test-race Run lifecycle and concurrency regressions with the race detector.
make fmt-check Check tracked Go files against gofmt.
make lint fmt-check plus go vet ./....

The repository's Go CI (.github/workflows/go.yml) runs make fmt-check, go vet ./..., go build ./..., make test, and make test-race on pushes and pull requests; run the same targets locally before submitting changes.

Health Probes and Shutdown

  • /health is the liveness probe and only says the process is running. /readyz is the readiness probe: it returns 200 once assembly has finished and the database is reachable, and 503 while starting, shutting down, or when the database is unavailable. Point load-balancer or Kubernetes readiness checks at /readyz.
  • Send SIGTERM for a graceful stop: the server withdraws readiness, drains in-flight requests, stops plugin background work and workers, and finally closes caches and the database. The two phases take up to 10 seconds each, so give orchestrators a termination grace period of at least 25 seconds.
  • A listener failure such as a port already in use makes the process exit with a non-zero status instead of leaving a process that serves nothing.

See the Architecture Overview.

Database Migrations

The server applies pending database migrations on every start, before it reports ready. To look at them or apply them without serving HTTP, run the server binary with -migrate:

./build/gopress-server -config sites/example.com/config.toml -migrate=status
./build/gopress-server -config sites/example.com/config.toml -migrate=up

Back up the database before deploying a release. See Versioned Migrations.

Resetting Two-Step Verification

If an admin lost both their phone and their recovery codes and no other super admin can reset their two-step verification in the admin, turn it off on the server:

./build/gopress-server -config sites/example.com/config.toml -reset-2fa admin

The command ends the account's sessions, writes the audit log and exits without serving HTTP. The account signs in with its password and sets two-step verification up again. Anyone who can run it can also read config.toml, so it gives no access that the server shell does not already give.

Common Development Commands

Examples use ./build/gopress (local build). After make install you can drop the ./build/ prefix.

# Run the server (with autoload regenerated)
./build/gopress serve

# Forward flags to cmd/server
./build/gopress serve -config sites/localhost/config.toml
./build/gopress serve -seed

# Preview a theme package locally (a directory or a .zip; repeatable; not in release mode)
./build/gopress serve -theme-package ../aurora

# Regenerate autoload only (does not start anything)
./build/gopress gen

# Generate Swagger docs
go run ./cmd/gendoc

# Run tests
go test ./...

Adding a New Theme or Plugin

  1. Drop the folder into themes/ or plugins/.
  2. Make sure it contains a theme.toml (theme) or plugin.toml (plugin) and at least one non-test .go file at its root.
  3. Re-run ./build/gopress serve. The autoload file is regenerated and the new module is imported on startup.

No edit to cmd/server/main.go is required.

Media Processing Dependency

The Go standard library handles JPEG/PNG decoding, resizing, and encoding. Optional WebP output requires the cwebp command:

# macOS
brew install webp

# Debian/Ubuntu
apt-get install webp

Without cwebp, GoPress still generates resized JPEG/PNG variants and theme helpers fall back automatically. See Media Variants.

After Installation

  • Visit /admin to manage content, themes, plugins, media, users, and settings.
  • Use System Settings to set site name, site description, site language, admin language, favicon, and Powered by GoPress display.
  • Use Themes to activate a theme and import demo data.
  • Use Plugins to enable multilingual support, SEO extras, code snippets, or custom plugins.