WIP: Prebuilt docker image #803

Draft
floatingghost wants to merge 37 commits from customizable-docker-db into develop
3 changed files with 39 additions and 3 deletions
Showing only changes of commit 4450f7463b - Show all commits

View file

@ -0,0 +1,28 @@
#!/bin/bash
set -euo pipefail
mkdir -p pgdata
mkdir -p docker-setup-tmp
# This is sorta special in that we need the generated_config.exs to make it onto the host
# We can also automate the DB setup here!
docker compose run \
--rm \
-e "PLEROMA_CTL_RPC_DISABLED=true" \
-v ./docker-setup-tmp:/opt/akkoma/config/\
akkoma ./bin/pleroma_ctl instance gen --no-sql-user --no-db-creation --dbhost db --dbname akkoma --dbuser akkoma --dbpass akkoma --listen-ip 0.0.0.0 --listen-port 4000 --static-dir /opt/akkoma/instance/ --uploads-dir /opt/akkoma/uploads/ --db-configurable true
echo ""
echo "=========================="
echo ""
echo "Setting up your database!"
docker compose start db
docker compose run \
--rm \
-e "PGPASSWORD=akkoma" \
-v "$(pwd)/docker-setup-tmp/setup_db.psql:/docker-entrypoint-initdb.d/setup_db.sql" \
db

View file

@ -37,7 +37,9 @@ def run(["gen" | rest]) do
listen_port: :string, listen_port: :string,
strip_uploads_metadata: :string, strip_uploads_metadata: :string,
read_uploads_description: :string, read_uploads_description: :string,
anonymize_uploads: :string anonymize_uploads: :string,
no_sql_user: :boolean,
no_db_creation: :boolean
], ],
aliases: [ aliases: [
o: :output, o: :output,
@ -260,7 +262,9 @@ def run(["gen" | rest]) do
dbname: dbname, dbname: dbname,
dbuser: dbuser, dbuser: dbuser,
dbpass: dbpass, dbpass: dbpass,
rum_enabled: rum_enabled rum_enabled: rum_enabled,
no_sql_user: Keyword.get(options, :no_sql_user, false),
no_db_creation: Keyword.get(options, :no_db_creation, false)
) )
config_dir = Path.dirname(config_path) config_dir = Path.dirname(config_path)

View file

@ -1,5 +1,9 @@
<%= unless no_sql_user do %>
CREATE USER <%= dbuser %> WITH ENCRYPTED PASSWORD '<%= dbpass %>'; CREATE USER <%= dbuser %> WITH ENCRYPTED PASSWORD '<%= dbpass %>';
CREATE DATABASE <%= dbname %> OWNER <%= dbuser %>; <% end %>
<%= unless no_db_creation do %>
CREATE DATABASE IF NOT EXISTS <%= dbname %> OWNER <%= dbuser %>;
<% end %>
\c <%= dbname %>; \c <%= dbname %>;
--Extensions made by ecto.migrate that need superuser access --Extensions made by ecto.migrate that need superuser access
CREATE EXTENSION IF NOT EXISTS citext; CREATE EXTENSION IF NOT EXISTS citext;