diff --git a/README.md b/README.md index 3a3bcf9..7298f96 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ docker run -p 7000:7000 -e GOBLOG_DATA_DIR=/data -v goblog-data:/data compscidr/ ``` `GOBLOG_DATA_DIR` is where goblog keeps everything it writes: `.env` (the session key, database settings and GitHub credentials the wizard saves), the SQLite database, uploads, and installed plugins and themes. With it on a volume, the site survives the container being replaced, for example when you pull a newer image. Without it those files are written inside the container and are lost with it. +The same with Docker Compose is in [`docker-compose.yml`](docker-compose.yml): `docker compose up -d`, then `docker compose logs goblog | grep "setup code"`. It has a commented-out PostgreSQL service for those who want one. + A relative SQLite path such as the wizard's default `goblog.db` is created inside the data directory; an absolute path is used as given. Sites set up before `GOBLOG_DATA_DIR` existed keep working unchanged when it is not set. ### Database diff --git a/docker-compose.yml b/docker-compose.yml index d75166b..4486f21 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,56 +1,39 @@ -version: "3.0" +# goblog with SQLite: one container, one volume. Everything goblog writes +# (.env, the database, uploads, installed plugins and themes) lives in the +# goblog-data volume, so `docker compose pull && docker compose up -d` +# upgrades without losing the site. +# +# docker compose up -d +# docker compose logs goblog | grep "setup code" +# +# then open http://localhost:7000 and follow the install wizard. services: - db: - container_name: db - image: mysql:9.6 - restart: always - env_file: - template.env + goblog: + image: compscidr/goblog:latest + # To run what is checked out here instead of the released image: + # build: . + restart: unless-stopped + environment: + GOBLOG_DATA_DIR: /data ports: - - "3306:3306" + - "7000:7000" + volumes: + - goblog-data:/data - # Alternative to the mysql service above: set database=postgres and the - # POSTGRES_* variables in template.env, then swap the goblog service's - # depends_on to db-postgres. - # db-postgres: - # container_name: db-postgres + # PostgreSQL instead of SQLite: uncomment this service and the volume + # below, run `docker compose up -d`, and in the install wizard choose + # PostgreSQL with host "postgres", user and database "goblog" and the + # password set here. MySQL works the same way with the mysql:9 image. + # postgres: # image: postgres:16-alpine - # restart: always + # restart: unless-stopped # environment: # POSTGRES_DB: goblog # POSTGRES_USER: goblog - # POSTGRES_PASSWORD: somedbpass - # ports: - # - "5432:5432" + # POSTGRES_PASSWORD: change-me # volumes: - # - ./pgdata:/var/lib/postgresql/data - - phpmyadmin: - depends_on: - - db - container_name: phpmyadmin - image: phpmyadmin/phpmyadmin - restart: always - env_file: - template.env - ports: - - '8080:80' + # - postgres-data:/var/lib/postgresql/data - goblog: - build: - context: . - args: - VERSION: develop - image: compscidr/goblog:latest - container_name: goblog - depends_on: - - db - restart: always - env_file: - template.env - ports: - - "7000:7000" - volumes: - - ./template.env:/go/src/github.com/compscidr/goblog/local.env - - ../:/var/www/html/ - - ${PWD}/test.db:/go/src/github.com/compscidr/goblog/test.db \ No newline at end of file +volumes: + goblog-data: + # postgres-data: diff --git a/template.env b/template.env index 792fda1..07092e9 100644 --- a/template.env +++ b/template.env @@ -1,24 +1,41 @@ -# database (sqlite, mysql or postgres) -database=mysql -sqlite_db=../db +# goblog's .env, for setting a site up without the install wizard (from +# configuration management, say). The wizard writes this file itself, so a +# normal install does not need it. goblog reads .env from its working +# directory, or from GOBLOG_DATA_DIR when that is set; values already in the +# process environment take precedence. +# +# Without an admin, the wizard still opens to create one (it asks for the +# setup code goblog prints to its log); or set client_id/client_secret below +# and the first GitHub login becomes the admin. -# only required to use mysql database -MYSQL_ROOT_PASSWORD=something -MYSQL_DATABASE=goblog -MYSQL_USER=someuser -MYSQL_PASSWORD=somedbpass +# the session cookie's signing key: 36 characters, e.g. from `uuidgen`. +# goblog writes one if it is missing; changing it signs everybody out. +# SESSION_KEY= -# only required to use postgres database +# database: sqlite, mysql or postgres +database=sqlite +# a relative path is inside GOBLOG_DATA_DIR when that is set +sqlite_db=goblog.db + +# mysql +# MYSQL_HOST=localhost +# MYSQL_PORT=3306 +# MYSQL_USER=goblog +# MYSQL_PASSWORD= +# MYSQL_DATABASE=goblog + +# postgres # POSTGRES_HOST=localhost # POSTGRES_PORT=5432 # POSTGRES_USER=goblog -# POSTGRES_PASSWORD=somedbpass +# POSTGRES_PASSWORD= # POSTGRES_DATABASE=goblog # POSTGRES_SSLMODE=disable -# github auth credentials -client_id= -client_secret= +# optional: GitHub login, from a GitHub OAuth app whose callback URL is +# https:///login +# client_id= +# client_secret= # optional: pin admin promotion to a specific GitHub account. When either is # set, only a matching user is promoted to admin on first login; when both are @@ -29,8 +46,8 @@ client_secret= # optional: email (one-time code) login for visitors. Enabled when both # smtp_host and smtp_from are set. smtp_port 465 uses implicit TLS; any other # port (default 587) uses STARTTLS when the server offers it. Leave smtp_user -# unset for a relay that does not need authentication. Admin login stays -# GitHub-only. +# unset for a relay that does not need authentication. Email users cannot be +# admins. # smtp_host=smtp.example.com # smtp_port=587 # smtp_user=postmaster@example.com