feat: use sqlite by default

This commit is contained in:
Mac Chaffee
2025-09-08 21:29:30 -04:00
parent a1810daa0f
commit 0eaed4920f
7 changed files with 69 additions and 68 deletions

View File

@ -4,6 +4,7 @@ DOMAIN=writefreely.example.com
HOST_URL=https://${DOMAIN} HOST_URL=https://${DOMAIN}
SITE_NAME=writefreely SITE_NAME=writefreely
# See https://writefreely.org/docs/main/admin/config
FEDERATION=true FEDERATION=true
LOCAL_TIMELINE=false LOCAL_TIMELINE=false
OPEN_DELETION=false OPEN_DELETION=false
@ -13,6 +14,12 @@ PUBLIC_STATS=true
SITE_DESCRIPTION= SITE_DESCRIPTION=
SITE_EDITOR=classic SITE_EDITOR=classic
SITE_THEME=write SITE_THEME=write
WEBFONTS=true
CHORUS=false
FOREST=false
SINGLE_USER=false
MAX_BLOGS="10"
DISABLE_PASSWORD_AUTH=true
#This is here so later lines can extend it; you likely don't wanna edit #This is here so later lines can extend it; you likely don't wanna edit
COMPOSE_FILE="compose.yml" COMPOSE_FILE="compose.yml"
@ -21,6 +28,9 @@ COMPOSE_FILE="compose.yml"
#EXTRA_DOMAINS=', `www.writefreely.example.com`' #EXTRA_DOMAINS=', `www.writefreely.example.com`'
LETS_ENCRYPT_ENV=production LETS_ENCRYPT_ENV=production
## Uncomment to use mariadb instead of sqlite
#COMPOSE_FILE="$COMPOSE_FILE:compose.mariadb.yml"
#USE_MARIADB=true
SECRET_DB_ROOT_PASSWORD_VERSION=v1 SECRET_DB_ROOT_PASSWORD_VERSION=v1
SECRET_DB_PASSWORD_VERSION=v1 SECRET_DB_PASSWORD_VERSION=v1

View File

@ -1,7 +1,5 @@
# writefreely # writefreely
> 📢📢📢 UPDATE IN PROGRESS, SEE [`#1`](https://git.coopcloud.tech/coop-cloud/writefreely/issues/1) 📢📢📢
> An open source platform for building a writing space on the web. > An open source platform for building a writing space on the web.
<!-- metadata --> <!-- metadata -->
@ -28,14 +26,6 @@
5. `abra app deploy <domain>` 5. `abra app deploy <domain>`
6. Open the configured domain in your browser to finish set-up 6. Open the configured domain in your browser to finish set-up
## Post-install
```
passwd=`abra app run <domain> db cat /run/secrets/db_password`
abra app run <domain> db mysql -u writeas -p$passwd writefreely
ALTER TABLE `oauth_users` MODIFY `access_token` varchar(2048);
```
## Keycloak setup ## Keycloak setup
For the **OAUTH_HOST** config, it uses this format: `https://keycloak.domain.here/auth/realms/<your realm>/protocol/openid-connect`. For the **OAUTH_HOST** config, it uses this format: `https://keycloak.domain.here/auth/realms/<your realm>/protocol/openid-connect`.

35
compose.mariadb.yml Normal file
View File

@ -0,0 +1,35 @@
---
version: "3.8"
services:
app:
environment:
- DB_PASSWORD_FILE=/run/secrets/db_password
secrets:
- db_password
db:
image: "mariadb:10.11"
environment:
- MYSQL_DATABASE=writefreely
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
- MYSQL_USER=writeas
volumes:
- "db:/var/lib/mysql"
networks:
- internal
secrets:
- db_root_password
- db_password
volumes:
db:
secrets:
db_root_password:
external: true
name: ${STACK_NAME}_db_root_password_${SECRET_DB_ROOT_PASSWORD_VERSION}
db_password:
external: true
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}

View File

@ -3,9 +3,8 @@ version: "3.8"
services: services:
app: app:
image: git.coopcloud.tech/coop-cloud-chaos-patchs/writefreely:v0.15.1 image: git.coopcloud.tech/coop-cloud-chaos-patchs/writefreely:v0.16.0
environment: environment:
- DB_PASSWORD_FILE=/run/secrets/db_password
- FEDERATION - FEDERATION
- HOST_URL - HOST_URL
- LOCAL_TIMELINE - LOCAL_TIMELINE
@ -20,8 +19,6 @@ services:
configs: configs:
- source: config_ini - source: config_ini
target: /go/config.ini target: /go/config.ini
secrets:
- db_password
volumes: volumes:
- "web-keys:/go/keys" - "web-keys:/go/keys"
networks: networks:
@ -42,38 +39,14 @@ services:
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
- "coop-cloud.${STACK_NAME}.version=0.1.0+latest" - "coop-cloud.${STACK_NAME}.version=0.1.0+latest"
db:
image: "mariadb:10.7"
environment:
- MYSQL_DATABASE=writefreely
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db_root_password
- MYSQL_PASSWORD_FILE=/run/secrets/db_password
- MYSQL_USER=writeas
volumes:
- "db:/var/lib/mysql"
networks:
- internal
secrets:
- db_root_password
- db_password
volumes: volumes:
web-keys: web-keys:
db:
networks: networks:
proxy: proxy:
external: true external: true
internal: internal:
secrets:
db_root_password:
external: true
name: ${STACK_NAME}_db_root_password_${SECRET_DB_ROOT_PASSWORD_VERSION}
db_password:
external: true
name: ${STACK_NAME}_db_password_${SECRET_DB_PASSWORD_VERSION}
configs: configs:
config_ini: config_ini:
name: ${STACK_NAME}_config_${CONFIG_WRITEFREELY_VERSION} name: ${STACK_NAME}_config_${CONFIG_WRITEFREELY_VERSION}

View File

@ -13,12 +13,12 @@ hash_seed =
gopher_port = 0 gopher_port = 0
[database] [database]
type = mysql type = {{ if eq (env "USE_MARIADB") "true" }}mysql{{ else }}sqlite3{{ end }}
filename = filename = {{ if eq (env "USE_MARIADB") "true" }}{{ else }}writefreely.db{{ end }}
username = writeas username = {{ if eq (env "USE_MARIADB") "true" }}writeas{{ else }}{{ end }}
password = {{ secret "db_password" }} password = {{ if eq (env "USE_MARIADB") "true" }}{{ secret "db_password" }}{{ else }}{{ end }}
database = writefreely database = {{ if eq (env "USE_MARIADB") "true" }}writefreely{{ else }}{{ end }}
host = db host = {{ if eq (env "USE_MARIADB") "true" }}db{{ else }}localhost{{ end }}
port = 3306 port = 3306
tls = false tls = false
@ -29,18 +29,18 @@ host = {{ env "HOST_URL" }}
theme = {{ env "SITE_THEME" }} theme = {{ env "SITE_THEME" }}
editor = {{ env "SITE_EDITOR" }} editor = {{ env "SITE_EDITOR" }}
disable_js = false disable_js = false
webfonts = true webfonts = {{ env "WEBFONTS" }}
landing = landing =
simple_nav = false simple_nav = false
wf_modesty = false wf_modesty = false
chorus = false chorus = {{ env "CHORUS" }}
forest = false forest = {{ env "FOREST" }}
disable_drafts = false disable_drafts = false
single_user = false single_user = {{ env "SINGLE_USER" }}
open_registration = {{ env "OPEN_REGISTRATION" }} open_registration = {{ env "OPEN_REGISTRATION" }}
open_deletion = {{ env "OPEN_DELETION" }} open_deletion = {{ env "OPEN_DELETION" }}
min_username_len = 3 min_username_len = 3
max_blogs = 10 max_blogs = {{ env "MAX_BLOGS" }}
federation = {{ env "FEDERATION" }} federation = {{ env "FEDERATION" }}
public_stats = {{ env "PUBLIC_STATS" }} public_stats = {{ env "PUBLIC_STATS" }}
monetization = false monetization = false
@ -50,7 +50,7 @@ local_timeline = {{ env "LOCAL_TIMELINE" }}
user_invites = user_invites =
default_visibility = default_visibility =
update_checks = false update_checks = false
disable_password_auth = true disable_password_auth = {{ env "DISABLE_PASSWORD_AUTH" }}
{{ if eq (env "KEYCLOAK_ENABLED") "1" }} {{ if eq (env "KEYCLOAK_ENABLED") "1" }}
[oauth.generic] [oauth.generic]

View File

@ -1,18 +0,0 @@
#!/bin/bash
function show_help () {
echo "usage: ./first_deploy.sh [app name]"
}
if [[ $1 == "" ]]; then
show_help
exit 1
fi
app=$1
abra app run $app app /go/cmd/writefreely/writefreely --init-db
passwd=`abra app run $app db cat /run/secrets/db_password`
echo 'ALTER TABLE `oauth_users` MODIFY `access_token` varchar(2048)' | abra app run $app db mysql -u writeas -p$passwd writefreely
exit 0

11
release/next Normal file
View File

@ -0,0 +1,11 @@
MAJOR CHANGE! PLEASE READ!
This release changes the default database from mariadb to sqlite.
If you were previously using mariadb, you MUST add the following to your config:
COMPOSE_FILE="$COMPOSE_FILE:compose.mariadb.yml"
USE_MARIADB=true
If you want to migrate to using sqlite, you can export all posts before upgrading, then import all
posts after upgrading.