Compare commits
No commits in common. "8a43244c0ccfc4b095672d573593cb86d8348c05" and "bc3f513f6d257ce62449ce8bd5f960d0eb87fe0d" have entirely different histories.
8a43244c0c
...
bc3f513f6d
15 changed files with 32 additions and 188 deletions
10
Dockerfile
10
Dockerfile
|
@ -20,16 +20,12 @@ RUN addgroup -g ${GID} akkoma \
|
||||||
|
|
||||||
WORKDIR ${BUILD_DIR}
|
WORKDIR ${BUILD_DIR}
|
||||||
|
|
||||||
RUN mix local.hex --force \
|
|
||||||
&& mix local.rebar --force
|
|
||||||
|
|
||||||
COPY ./mix.exs ./mix.lock ./
|
|
||||||
|
|
||||||
RUN mix deps.get --only ${MIX_ENV}
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN mkdir -p "${BUILD_DIR}_build/" \
|
RUN mkdir -p "${BUILD_DIR}_build/" \
|
||||||
|
&& mix local.hex --force \
|
||||||
|
&& mix local.rebar --force \
|
||||||
|
&& mix deps.get --only prod \
|
||||||
&& mix release --path "${BUILD_DIR}_build"
|
&& mix release --path "${BUILD_DIR}_build"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
## What is this?
|
## What is This?
|
||||||
|
|
||||||
This is a fork of [AkkomaGang/akkoma](https://akkoma.dev/AkkomaGang/akkoma/), with some opinionated changes to satisfy my needs.
|
This is a fork of [AkkomaGang/akkoma](https://akkoma.dev/AkkomaGang/akkoma/), with an opinionated Docker setup.
|
||||||
|
|
||||||
The differences between the upstream repository are described below:
|
The differences between the upstream repository are described below:
|
||||||
|
|
||||||
- Uses the official Elixir image from Docker Hub
|
- Uses the official Elixir image from Docker Hub
|
||||||
- Automatically builds the Akkoma backend when building the Docker image, instead of requiring complex commands after pulling/building images
|
- Automatically builds the Akkoma backend when building the Docker image, instead of requiring complex commands after pulling/building images
|
||||||
- Files/directories to mount are minified and completely separated from the repository files, allowing better control over file permissions
|
- Files/directories to mount are minified and completely separated from the repository files, allowing better control over file permissions
|
||||||
- Has an actual Docker entry point, rather than a command that pretends to be an entry point
|
- Has an "actual" Docker entry point that works the way Docker entry points are supposed to work
|
||||||
- Has out-of-the-box support for PGroonga, the fast and accurate full-text search extension for PostgreSQL
|
|
||||||
- Supports Podman quite well
|
- Supports Podman quite well
|
||||||
|
|
||||||
## How to Setup (Podman Rootless)
|
## How to Setup (Podman Rootless)
|
||||||
|
@ -22,7 +21,7 @@ The differences between the upstream repository are described below:
|
||||||
|
|
||||||
### 1. Build your image
|
### 1. Build your image
|
||||||
|
|
||||||
This will take 5+ minutes.
|
This will take 10+ minutes.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd /YOUR/GIT/DIRECTORY/akkoma/
|
cd /YOUR/GIT/DIRECTORY/akkoma/
|
||||||
|
|
|
@ -71,14 +71,8 @@
|
||||||
config :pleroma, :http_security, report_uri: "https://endpoint.com"
|
config :pleroma, :http_security, report_uri: "https://endpoint.com"
|
||||||
|
|
||||||
rum_enabled = System.get_env("RUM_ENABLED") == "true"
|
rum_enabled = System.get_env("RUM_ENABLED") == "true"
|
||||||
pgroonga_enabled = System.get_env("PGROONGA_ENABLED") == "true"
|
config :pleroma, :database, rum_enabled: rum_enabled
|
||||||
|
|
||||||
config :pleroma, :database,
|
|
||||||
rum_enabled: rum_enabled,
|
|
||||||
pgroonga_enabled: pgroonga_enabled
|
|
||||||
|
|
||||||
IO.puts("RUM enabled: #{rum_enabled}")
|
IO.puts("RUM enabled: #{rum_enabled}")
|
||||||
IO.puts("PGroonga enabled: #{pgroonga_enabled}")
|
|
||||||
|
|
||||||
config :pleroma, Pleroma.ReverseProxy.Client, Pleroma.ReverseProxy.ClientMock
|
config :pleroma, Pleroma.ReverseProxy.Client, Pleroma.ReverseProxy.ClientMock
|
||||||
|
|
||||||
|
|
|
@ -689,9 +689,7 @@
|
||||||
issue_new_refresh_token: true,
|
issue_new_refresh_token: true,
|
||||||
clean_expired_tokens: false
|
clean_expired_tokens: false
|
||||||
|
|
||||||
config :pleroma, :database,
|
config :pleroma, :database, rum_enabled: false
|
||||||
rum_enabled: false,
|
|
||||||
pgroonga_enabled: false
|
|
||||||
|
|
||||||
config :pleroma, :features, improved_hashtag_timeline: :auto
|
config :pleroma, :features, improved_hashtag_timeline: :auto
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,7 @@
|
||||||
# Configure web push notifications
|
# Configure web push notifications
|
||||||
config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"
|
config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"
|
||||||
|
|
||||||
config :pleroma, :database,
|
config :pleroma, :database, rum_enabled: false
|
||||||
rum_enabled: false,
|
|
||||||
pgroonga_enabled: false
|
|
||||||
|
|
||||||
config :pleroma, :instance, static_dir: "/var/lib/akkoma/static"
|
config :pleroma, :instance, static_dir: "/var/lib/akkoma/static"
|
||||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/akkoma/uploads"
|
config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/akkoma/uploads"
|
||||||
|
|
||||||
|
|
|
@ -98,14 +98,8 @@
|
||||||
config :pleroma, :http, send_user_agent: false
|
config :pleroma, :http, send_user_agent: false
|
||||||
|
|
||||||
rum_enabled = System.get_env("RUM_ENABLED") == "true"
|
rum_enabled = System.get_env("RUM_ENABLED") == "true"
|
||||||
pgroonga_enabled = System.get_env("PGROONGA_ENABLED") == "true"
|
config :pleroma, :database, rum_enabled: rum_enabled
|
||||||
|
|
||||||
config :pleroma, :database,
|
|
||||||
rum_enabled: rum_enabled,
|
|
||||||
pgroonga_enabled: pgroonga_enabled
|
|
||||||
|
|
||||||
IO.puts("RUM enabled: #{rum_enabled}")
|
IO.puts("RUM enabled: #{rum_enabled}")
|
||||||
IO.puts("PGroonga enabled: #{pgroonga_enabled}")
|
|
||||||
|
|
||||||
config :joken, default_signer: "yU8uHKq+yyAkZ11Hx//jcdacWc8yQ1bxAAGrplzB0Zwwjkp35v0RK9SO8WTPr6QZ"
|
config :joken, default_signer: "yU8uHKq+yyAkZ11Hx//jcdacWc8yQ1bxAAGrplzB0Zwwjkp35v0RK9SO8WTPr6QZ"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ version: "3.7"
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:14-alpine
|
image: postgres:14-alpine
|
||||||
# image: groonga/pgroonga:3.1.1-alpine-14 # Use this one if you want to use PGroonga
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: akkoma
|
POSTGRES_DB: akkoma
|
||||||
|
|
|
@ -54,7 +54,6 @@ The configuration of Akkoma (and Pleroma) has traditionally been managed with a
|
||||||
* config :pleroma, Pleroma.Repo
|
* config :pleroma, Pleroma.Repo
|
||||||
* config :pleroma, configurable\_from\_database
|
* config :pleroma, configurable\_from\_database
|
||||||
* config :pleroma, :database, rum_enabled
|
* config :pleroma, :database, rum_enabled
|
||||||
* config :pleroma, :database, pgroonga_enabled
|
|
||||||
* config :pleroma, :connections_pool
|
* config :pleroma, :connections_pool
|
||||||
|
|
||||||
Here is an example of a server config stripped down after migration:
|
Here is an example of a server config stripped down after migration:
|
||||||
|
|
|
@ -326,50 +326,37 @@ def run(["set_text_search_config", tsconfig]) do
|
||||||
"ALTER DATABASE #{db} SET default_text_search_config = '#{tsconfig}';"
|
"ALTER DATABASE #{db} SET default_text_search_config = '#{tsconfig}';"
|
||||||
)
|
)
|
||||||
|
|
||||||
# non-exist config will not raise exception but only give >0 messages
|
# non-exist config will not raise excpetion but only give >0 messages
|
||||||
if length(msg) > 0 do
|
if length(msg) > 0 do
|
||||||
shell_info("Error: #{inspect(msg, pretty: true)}")
|
shell_info("Error: #{inspect(msg, pretty: true)}")
|
||||||
else
|
else
|
||||||
rum_enabled = Pleroma.Config.get([:database, :rum_enabled])
|
rum_enabled = Pleroma.Config.get([:database, :rum_enabled])
|
||||||
pgroonga_enabled = Pleroma.Config.get([:database, :pgroonga_enabled])
|
shell_info("Recreate index, RUM: #{rum_enabled}")
|
||||||
shell_info("Recreate index, RUM: #{rum_enabled}, PGroonga: #{pgroonga_enabled}")
|
|
||||||
|
|
||||||
# Note SQL below needs to be kept up-to-date with latest GIN or RUM index definition in future
|
# Note SQL below needs to be kept up-to-date with latest GIN or RUM index definition in future
|
||||||
cond do
|
if rum_enabled do
|
||||||
rum_enabled ->
|
Ecto.Adapters.SQL.query!(
|
||||||
Ecto.Adapters.SQL.query!(
|
Pleroma.Repo,
|
||||||
Pleroma.Repo,
|
"CREATE OR REPLACE FUNCTION objects_fts_update() RETURNS trigger AS $$ BEGIN
|
||||||
"CREATE OR REPLACE FUNCTION objects_fts_update() RETURNS trigger AS $$ BEGIN
|
|
||||||
new.fts_content := to_tsvector(new.data->>'content');
|
new.fts_content := to_tsvector(new.data->>'content');
|
||||||
RETURN new;
|
RETURN new;
|
||||||
END
|
END
|
||||||
$$ LANGUAGE plpgsql",
|
$$ LANGUAGE plpgsql",
|
||||||
[],
|
[],
|
||||||
timeout: :infinity
|
timeout: :infinity
|
||||||
)
|
)
|
||||||
|
|
||||||
shell_info("Refresh RUM index")
|
shell_info("Refresh RUM index")
|
||||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "UPDATE objects SET updated_at = NOW();")
|
Ecto.Adapters.SQL.query!(Pleroma.Repo, "UPDATE objects SET updated_at = NOW();")
|
||||||
|
else
|
||||||
|
Ecto.Adapters.SQL.query!(Pleroma.Repo, "DROP INDEX IF EXISTS objects_fts;")
|
||||||
|
|
||||||
pgroonga_enabled ->
|
Ecto.Adapters.SQL.query!(
|
||||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "DROP INDEX IF EXISTS object_content_pgroonga;")
|
Pleroma.Repo,
|
||||||
|
"CREATE INDEX CONCURRENTLY objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); ",
|
||||||
Ecto.Adapters.SQL.query!(
|
[],
|
||||||
Pleroma.Repo,
|
timeout: :infinity
|
||||||
"CREATE INDEX object_content_pgroonga ON objects USING pgroonga ((data->'content')) WITH (tokenizer='TokenMecab');",
|
)
|
||||||
[],
|
|
||||||
timeout: :infinity
|
|
||||||
)
|
|
||||||
|
|
||||||
true ->
|
|
||||||
Ecto.Adapters.SQL.query!(Pleroma.Repo, "DROP INDEX IF EXISTS objects_fts;")
|
|
||||||
|
|
||||||
Ecto.Adapters.SQL.query!(
|
|
||||||
Pleroma.Repo,
|
|
||||||
"CREATE INDEX CONCURRENTLY objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content'));",
|
|
||||||
[],
|
|
||||||
timeout: :infinity
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
shell_info('Done.')
|
shell_info('Done.')
|
||||||
|
|
|
@ -28,7 +28,6 @@ def run(["gen" | rest]) do
|
||||||
dbuser: :string,
|
dbuser: :string,
|
||||||
dbpass: :string,
|
dbpass: :string,
|
||||||
rum: :string,
|
rum: :string,
|
||||||
pgroonga: :string,
|
|
||||||
indexable: :string,
|
indexable: :string,
|
||||||
db_configurable: :string,
|
db_configurable: :string,
|
||||||
uploads_dir: :string,
|
uploads_dir: :string,
|
||||||
|
@ -128,18 +127,6 @@ def run(["gen" | rest]) do
|
||||||
"n"
|
"n"
|
||||||
) === "y"
|
) === "y"
|
||||||
|
|
||||||
pgroonga_enabled =
|
|
||||||
if rum_enabled do
|
|
||||||
false
|
|
||||||
else
|
|
||||||
get_option(
|
|
||||||
options,
|
|
||||||
:pgroonga,
|
|
||||||
"Would you like to use PGroonga to index and search?",
|
|
||||||
"n"
|
|
||||||
) === "y"
|
|
||||||
end
|
|
||||||
|
|
||||||
listen_port =
|
listen_port =
|
||||||
get_option(
|
get_option(
|
||||||
options,
|
options,
|
||||||
|
@ -238,7 +225,6 @@ def run(["gen" | rest]) do
|
||||||
static_dir: static_dir,
|
static_dir: static_dir,
|
||||||
uploads_dir: uploads_dir,
|
uploads_dir: uploads_dir,
|
||||||
rum_enabled: rum_enabled,
|
rum_enabled: rum_enabled,
|
||||||
pgroonga_enabled: pgroonga_enabled,
|
|
||||||
listen_ip: listen_ip,
|
listen_ip: listen_ip,
|
||||||
listen_port: listen_port,
|
listen_port: listen_port,
|
||||||
upload_filters:
|
upload_filters:
|
||||||
|
|
|
@ -24,7 +24,6 @@ def verify! do
|
||||||
|> check_migrations_applied!()
|
|> check_migrations_applied!()
|
||||||
|> check_welcome_message_config!()
|
|> check_welcome_message_config!()
|
||||||
|> check_rum!()
|
|> check_rum!()
|
||||||
|> check_pgroonga!()
|
|
||||||
|> check_repo_pool_size!()
|
|> check_repo_pool_size!()
|
||||||
|> handle_result()
|
|> handle_result()
|
||||||
end
|
end
|
||||||
|
@ -163,55 +162,6 @@ defp do_check_rum!(setting, migrate) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Checks for settings of PGroonga.
|
|
||||||
#
|
|
||||||
defp check_pgroonga!(:ok) do
|
|
||||||
{_, res, _} =
|
|
||||||
Ecto.Migrator.with_repo(Pleroma.Repo, fn repo ->
|
|
||||||
# TODO: check migrate
|
|
||||||
migrate =
|
|
||||||
from(o in "pg_indexes",
|
|
||||||
where: o.indexname == "object_content_pgroonga"
|
|
||||||
)
|
|
||||||
|> repo.exists?()
|
|
||||||
|
|
||||||
setting = Pleroma.Config.get([:database, :pgroonga_enabled], false)
|
|
||||||
|
|
||||||
do_check_pgroonga!(setting, migrate)
|
|
||||||
end)
|
|
||||||
|
|
||||||
res
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_pgroonga!(result), do: result
|
|
||||||
|
|
||||||
defp do_check_pgroonga!(setting, migrate) do
|
|
||||||
case {setting, migrate} do
|
|
||||||
{true, false} ->
|
|
||||||
Logger.error(
|
|
||||||
"PGroonga is enabled, but no migrations have been applied for it.\n" <>
|
|
||||||
"If you want to start Akkoma without using PGroonga, set `config :pleroma, :database, pgroonga_enabled: false`.\n" <>
|
|
||||||
"Otherwise apply the following migrations:\n" <>
|
|
||||||
"`mix ecto.migrate --migrations-path priv/repo/optional_migrations/pgroonga/`"
|
|
||||||
)
|
|
||||||
|
|
||||||
{:error, "Unapplied PGroonga Migrations detected"}
|
|
||||||
|
|
||||||
{false, true} ->
|
|
||||||
Logger.error(
|
|
||||||
"Detected applied migrations to use PGroonga to search, but it is not enabled in the settings.\n" <>
|
|
||||||
"If you want to use PGroonga, set `config :pleroma, :database, pgroonga_enabled: true`.\n" <>
|
|
||||||
"Otherwise apply the following migrations:\n" <>
|
|
||||||
"`mix ecto.rollback --migrations-path priv/repo/optional_migrations/pgroonga/`"
|
|
||||||
)
|
|
||||||
|
|
||||||
{:error, "PGroonga Migrations detected"}
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
:ok
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_system_commands!(:ok) do
|
defp check_system_commands!(:ok) do
|
||||||
filter_commands_statuses = [
|
filter_commands_statuses = [
|
||||||
check_filter(Pleroma.Upload.Filter.Exiftool, "exiftool"),
|
check_filter(Pleroma.Upload.Filter.Exiftool, "exiftool"),
|
||||||
|
|
|
@ -16,13 +16,7 @@ defmodule Pleroma.Search.DatabaseSearch do
|
||||||
@behaviour Pleroma.Search.SearchBackend
|
@behaviour Pleroma.Search.SearchBackend
|
||||||
|
|
||||||
def search(user, search_query, options \\ []) do
|
def search(user, search_query, options \\ []) do
|
||||||
index_type =
|
index_type = if Pleroma.Config.get([:database, :rum_enabled]), do: :rum, else: :gin
|
||||||
cond do
|
|
||||||
Pleroma.Config.get([:database, :rum_enabled]) -> :rum
|
|
||||||
Pleroma.Config.get([:database, :pgroonga_enabled]) -> :pgroonga
|
|
||||||
true -> :gin
|
|
||||||
end
|
|
||||||
|
|
||||||
limit = Enum.min([Keyword.get(options, :limit), 40])
|
limit = Enum.min([Keyword.get(options, :limit), 40])
|
||||||
offset = Keyword.get(options, :offset, 0)
|
offset = Keyword.get(options, :offset, 0)
|
||||||
author = Keyword.get(options, :author)
|
author = Keyword.get(options, :author)
|
||||||
|
@ -138,18 +132,6 @@ defp query_with(q, :rum, search_query, :websearch) do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp query_with(q, :pgroonga, search_query, _) do
|
|
||||||
# PGroonga only supports PostgreSQL version 11 or newer
|
|
||||||
from([a, o] in q,
|
|
||||||
where:
|
|
||||||
fragment(
|
|
||||||
"?->'content' &@~ ?",
|
|
||||||
o.data,
|
|
||||||
^search_query
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def maybe_restrict_local(q, user) do
|
def maybe_restrict_local(q, user) do
|
||||||
limit = Pleroma.Config.get([:instance, :limit_to_local_content], :unauthenticated)
|
limit = Pleroma.Config.get([:instance, :limit_to_local_content], :unauthenticated)
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
defmodule Pleroma.Repo.Migrations.CreatePgroongaIndex do
|
|
||||||
use Ecto.Migration
|
|
||||||
|
|
||||||
def up do
|
|
||||||
execute("CREATE EXTENSION IF NOT EXISTS pgroonga")
|
|
||||||
|
|
||||||
drop_if_exists(
|
|
||||||
index(:objects, ["(to_tsvector('english', data->>'content'))"],
|
|
||||||
using: :gin,
|
|
||||||
name: :objects_fts
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
execute(
|
|
||||||
"CREATE INDEX object_content_pgroonga ON objects USING pgroonga ((data->'content')) WITH (tokenizer='TokenMecab')"
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def down do
|
|
||||||
execute("DROP INDEX IF EXISTS object_content_pgroonga")
|
|
||||||
|
|
||||||
create_if_not_exists(
|
|
||||||
index(:objects, ["(to_tsvector('english', data->>'content'))"],
|
|
||||||
using: :gin,
|
|
||||||
name: :objects_fts
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -41,10 +41,7 @@ config :web_push_encryption, :vapid_details,
|
||||||
public_key: "<%= web_push_public_key %>",
|
public_key: "<%= web_push_public_key %>",
|
||||||
private_key: "<%= web_push_private_key %>"
|
private_key: "<%= web_push_private_key %>"
|
||||||
|
|
||||||
config :pleroma, :database,
|
config :pleroma, :database, rum_enabled: <%= rum_enabled %>
|
||||||
rum_enabled: <%= rum_enabled %>,
|
|
||||||
pgroonga_enabled: <%= pgroonga_enabled %>
|
|
||||||
|
|
||||||
config :pleroma, :instance, static_dir: "<%= static_dir %>"
|
config :pleroma, :instance, static_dir: "<%= static_dir %>"
|
||||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "<%= uploads_dir %>"
|
config :pleroma, Pleroma.Uploaders.Local, uploads: "<%= uploads_dir %>"
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,3 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
end %>
|
end %>
|
||||||
<%= if pgroonga_enabled do
|
|
||||||
"CREATE EXTENSION IF NOT EXISTS pgroonga;"
|
|
||||||
else
|
|
||||||
""
|
|
||||||
end %>
|
|
||||||
|
|
Loading…
Reference in a new issue