diff --git a/.env.sample b/.env.sample index f1dc727..18fb577 100644 --- a/.env.sample +++ b/.env.sample @@ -4,6 +4,7 @@ DOMAIN=writefreely.example.com HOST_URL=https://${DOMAIN} SITE_NAME=writefreely +# See https://writefreely.org/docs/main/admin/config FEDERATION=true LOCAL_TIMELINE=false OPEN_DELETION=false @@ -13,6 +14,12 @@ PUBLIC_STATS=true SITE_DESCRIPTION= SITE_EDITOR=classic 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 COMPOSE_FILE="compose.yml" @@ -21,6 +28,9 @@ COMPOSE_FILE="compose.yml" #EXTRA_DOMAINS=', `www.writefreely.example.com`' 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_PASSWORD_VERSION=v1 diff --git a/README.md b/README.md index eeac508..9dc8167 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # 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. @@ -28,14 +26,6 @@ 5. `abra app deploy ` 6. Open the configured domain in your browser to finish set-up -## Post-install - -``` -passwd=`abra app run db cat /run/secrets/db_password` -abra app run db mysql -u writeas -p$passwd writefreely -ALTER TABLE `oauth_users` MODIFY `access_token` varchar(2048); -``` - ## Keycloak setup For the **OAUTH_HOST** config, it uses this format: `https://keycloak.domain.here/auth/realms//protocol/openid-connect`. diff --git a/compose.mariadb.yml b/compose.mariadb.yml new file mode 100644 index 0000000..d0ba70f --- /dev/null +++ b/compose.mariadb.yml @@ -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} diff --git a/compose.yml b/compose.yml index 703769f..04bd4ba 100644 --- a/compose.yml +++ b/compose.yml @@ -3,9 +3,8 @@ version: "3.8" services: 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: - - DB_PASSWORD_FILE=/run/secrets/db_password - FEDERATION - HOST_URL - LOCAL_TIMELINE @@ -20,8 +19,6 @@ services: configs: - source: config_ini target: /go/config.ini - secrets: - - db_password volumes: - "web-keys:/go/keys" networks: @@ -42,38 +39,14 @@ services: - "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}" - "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: web-keys: - db: networks: proxy: external: true 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: config_ini: name: ${STACK_NAME}_config_${CONFIG_WRITEFREELY_VERSION} diff --git a/config.ini.tmpl b/config.ini.tmpl index 8cc2959..2f42b4b 100644 --- a/config.ini.tmpl +++ b/config.ini.tmpl @@ -13,12 +13,12 @@ hash_seed = gopher_port = 0 [database] -type = mysql -filename = -username = writeas -password = {{ secret "db_password" }} -database = writefreely -host = db +type = {{ if eq (env "USE_MARIADB") "true" }}mysql{{ else }}sqlite3{{ end }} +filename = {{ if eq (env "USE_MARIADB") "true" }}{{ else }}writefreely.db{{ end }} +username = {{ if eq (env "USE_MARIADB") "true" }}writeas{{ else }}{{ end }} +password = {{ if eq (env "USE_MARIADB") "true" }}{{ secret "db_password" }}{{ else }}{{ end }} +database = {{ if eq (env "USE_MARIADB") "true" }}writefreely{{ else }}{{ end }} +host = {{ if eq (env "USE_MARIADB") "true" }}db{{ else }}localhost{{ end }} port = 3306 tls = false @@ -29,18 +29,18 @@ host = {{ env "HOST_URL" }} theme = {{ env "SITE_THEME" }} editor = {{ env "SITE_EDITOR" }} disable_js = false -webfonts = true +webfonts = {{ env "WEBFONTS" }} landing = simple_nav = false wf_modesty = false -chorus = false -forest = false +chorus = {{ env "CHORUS" }} +forest = {{ env "FOREST" }} disable_drafts = false -single_user = false +single_user = {{ env "SINGLE_USER" }} open_registration = {{ env "OPEN_REGISTRATION" }} open_deletion = {{ env "OPEN_DELETION" }} min_username_len = 3 -max_blogs = 10 +max_blogs = {{ env "MAX_BLOGS" }} federation = {{ env "FEDERATION" }} public_stats = {{ env "PUBLIC_STATS" }} monetization = false @@ -50,7 +50,7 @@ local_timeline = {{ env "LOCAL_TIMELINE" }} user_invites = default_visibility = update_checks = false -disable_password_auth = true +disable_password_auth = {{ env "DISABLE_PASSWORD_AUTH" }} {{ if eq (env "KEYCLOAK_ENABLED") "1" }} [oauth.generic] diff --git a/first_deploy.sh b/first_deploy.sh deleted file mode 100755 index 39e3732..0000000 --- a/first_deploy.sh +++ /dev/null @@ -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 diff --git a/release/next b/release/next new file mode 100644 index 0000000..f55425c --- /dev/null +++ b/release/next @@ -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.