started rebased build - using main dockerfile from soapbox repo

This commit is contained in:
Paul Wilde 2022-11-11 15:08:42 +00:00
parent 8af7f65170
commit 99f0259867
15 changed files with 87 additions and 250 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
static
uploads
postgres
build
soapbox.zip

3
00-create-pod.sh Normal file → Executable file
View file

@ -6,7 +6,6 @@ touch config.exs
chown -R 911:911 ./uploads
podman pod create \
--name pleroma-pod \
--name rebased-pod \
-p 4000:4000
bash ./10-create-db.sh

14
10-build-rebased.sh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/bash
source ./script_config.sh
if [ ! -d ./build ]; then
git clone https://gitlab.com/soapbox-pub/rebased.git ./build
cd ./build
else
cd ./build
git pull
fi
podman build -f Dockerfile --build-arg="BUILD_DATE=$DATE" --build-arg="VCS_REF=$REBASED_VER" -t $REBASED_IMG

View file

@ -1,22 +0,0 @@
#!/bin/bash
first=false
if [[ ! -d ./postgres ]]; then
mkdir ./postgres
$first=true
fi
podman run -d \
--name pleroma-db \
--pod pleroma-pod \
-e POSTGRES_USER=pleroma \
-e POSTGRES_PASSWORD=CHANGHEME \
-e POSTGRES_DB=pleroma \
-v ./postgres:/var/lib/postgresql/data \
postgres:12.1-alpine
if [[ $first == true ]]; then
podman exec -i pleroma-db psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
exit 0
fi

View file

@ -1,10 +0,0 @@
#!/bin/bash
commit="$1"
if [[ "$1" == "" ]]; then
echo "No commit ID provided"
$commit="develop"
exit
fi
dt=$(date +"%Y%m%d")
podman build -f Containerfile --build-arg="PLEROMA_VER=$commit" -t pleroma:run-$dt-$commit

15
20-create-db.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
source ./script_config.sh
mkdir ./postgres -p
podman run -d \
--name rebased-db \
--pod rebased-pod \
-e POSTGRES_USER=$PG_USER \
-e POSTGRES_PASSWORD=$PG_PASS \
-e POSTGRES_DB=$PG_NAME \
-v ./postgres:/var/lib/postgresql/data \
postgres:14.6-alpine

28
30-run-rebased.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
source ./script_config.sh
echo Stopping old `rebased-web` container...
podman stop rebased-web
podman rm rebased-web
echo Creating new `rebased-web` container...
podman run -d \
--name rebased-web \
--pod rebased-pod \
-v ./uploads:/var/lib/pleroma/uploads:z \
-v ./static:/var/lib/pleroma/static:z \
-v ./config:/var/lib/pleroma/config:z \
-v ./config.exs:/etc/pleroma/config.exs:ro \
-e DOMAIN=social.example.com \
-e INSTANCE_NAME=rebased \
-e ADMIN_EMAIL=admin@example.com \
-e NOTIFY_EMAIL=notify@example.com \
-e DB_USER=rebased \
-e DB_PASS=rebased \
-e DB_NAME=rebased \
-e DB_HOST=localhost \
-e POSTGRES_HOST=localhost \
$REBASED_IMG

5
35-gen-config.sh Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
source ./script_config.sh
podman exec -it rebased-web /opt/pleroma/bin/pleroma_ctl instance gen

8
40-install-soapbox.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/bash
curl -L https://gitlab.com/soapbox-pub/soapbox/-/jobs/artifacts/develop/download?job=build-production -o soapbox.zip
unzip soapbox.zip -d ./static
mv ./static/static/* ./static/
mv ./static/static/.* ./static/
rm ./static/static -r

View file

@ -1,35 +0,0 @@
#!/bin/bash
if [[ $1 == "" ]]; then
echo "No Image tag provided"
exit
fi
echo Creating directories...
mkdir ./postgres
mkdir ./uploads
mkdir ./static
touch config.exs
chown -R 911:911 ./uploads
echo Stopping old `pleroma-web` container...
podman stop pleroma-web
podman rm pleroma-web
echo Creating new `pleroma-web` container...
podman run -d \
--name pleroma-web \
--pod pleroma-pod \
-v ./uploads:/var/lib/pleroma/uploads:z \
-v ./static:/var/lib/pleroma/static:z \
-v ./config.exs:/etc/pleroma/config.exs:ro \
-e DOMAIN=social.example.com \
-e INSTANCE_NAME=Pleroma \
-e ADMIN_EMAIL=admin@example.com \
-e NOTIFY_EMAIL=notify@example.com \
-e DB_USER=pleroma \
-e DB_PASS=pleroma \
-e DB_NAME=pleroma \
-e DB_HOST=localhost \
-e POSTGRES_HOST=localhost \
pleroma:$1

View file

@ -1,43 +0,0 @@
FROM elixir:1.11.4-alpine
ENV UID=911 GID=911 \
MIX_ENV=prod
ARG PLEROMA_VER=develop
ENV UID=911 GID=911 MIX_ENV=prod
ENV MIX_ENV=prod
RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories \
&& apk update \
&& apk add git gcc g++ musl-dev make cmake file-dev \
exiftool imagemagick libmagic ncurses postgresql-client ffmpeg
RUN addgroup -g ${GID} pleroma \
&& adduser -h /pleroma -s /bin/false -D -G pleroma -u ${UID} pleroma
ARG DATA=/var/lib/pleroma
RUN mkdir -p /etc/pleroma \
&& chown -R pleroma /etc/pleroma \
&& mkdir -p ${DATA}/uploads \
&& mkdir -p ${DATA}/static \
&& chown -R pleroma ${DATA}
USER pleroma
WORKDIR /pleroma
RUN git clone -b develop https://git.pleroma.social/pleroma/pleroma.git /pleroma \
&& git checkout ${PLEROMA_VER}
RUN echo "import Mix.Config" > config/prod.secret.exs \
&& mix local.hex --force \
&& mix local.rebar --force \
&& mix deps.get --only prod \
&& mkdir release \
&& mix release --path /pleroma
COPY ./config.exs /etc/pleroma/config.exs
EXPOSE 4000
ENTRYPOINT ["/pleroma/docker-entrypoint.sh"]

View file

@ -1,76 +0,0 @@
import Config
config :pleroma, Pleroma.Web.Endpoint,
url: [host: System.get_env("DOMAIN", "localhost"), scheme: "https", port: 443],
http: [ip: {0, 0, 0, 0}, port: 4000]
config :pleroma, :instance,
name: System.get_env("INSTANCE_NAME", "Pleroma"),
email: System.get_env("ADMIN_EMAIL"),
notify_email: System.get_env("NOTIFY_EMAIL"),
limit: 5000,
registrations_open: false,
federating: true,
healthcheck: true
config :pleroma, configurable_from_database: true
config :pleroma, :media_proxy,
enabled: false,
redirect_on_failure: true,
base_url: "https://example.tld"
config :pleroma, Pleroma.Repo,
adapter: Ecto.Adapters.Postgres,
username: System.get_env("DB_USER", "pleroma"),
password: System.fetch_env!("DB_PASS"),
database: System.get_env("DB_NAME", "pleroma"),
hostname: System.get_env("DB_HOST", "localhost"),
pool_size: 10
# Configure web push notifications
config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"
config :pleroma, :database, rum_enabled: false
config :pleroma, :instance, static_dir: "/var/lib/pleroma/static"
config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/pleroma/uploads"
# We can't store the secrets in this file, since this is baked into the docker image
if not File.exists?("/var/lib/pleroma/secret.exs") do
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
{web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
secret_file =
EEx.eval_string(
"""
import Config
config :pleroma, Pleroma.Web.Endpoint,
secret_key_base: "<%= secret %>",
signing_salt: "<%= signing_salt %>"
config :web_push_encryption, :vapid_details,
public_key: "<%= web_push_public_key %>",
private_key: "<%= web_push_private_key %>"
""",
secret: secret,
signing_salt: signing_salt,
web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false)
)
File.write("/var/lib/pleroma/secret.exs", secret_file)
end
import_config("/var/lib/pleroma/secret.exs")
# For additional user config
if File.exists?("/var/lib/pleroma/config.exs"),
do: import_config("/var/lib/pleroma/config.exs"),
else:
File.write("/var/lib/pleroma/config.exs", """
import Config
# For additional configuration outside of environmental variables
""")

View file

@ -1,62 +0,0 @@
#!/bin/bash
mkdir ./postgres
mkdir ./uploads
mkdir ./static
touch config.exs
chown -R 911:911 ./uploads
podman pod create \
--name pleroma-pod \
-p 4000:4000
podman run -d \
--name pleroma-db \
--pod pleroma-pod \
-e POSTGRES_USER=pleroma \
-e POSTGRES_PASSWORD=CHANGHEME \
-e POSTGRES_DB=pleroma \
-v ./postgres:/var/lib/postgresql/data \
postgres:12.1-alpine
if [[ $1 == "db-setup" ]]; then
podman exec -i pleroma-db psql -U pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
exit 0
fi
runvars="pleroma:"
runmode="-d"
if [[ $1 == "build-setup" ]]; then
podman build -f Dockerfile -t pleroma:$1
runvars=$runvars$1" mix ecto.migrate"
runmode="--rm"
elif [[ $1 == "final-build" ]]; then
podman build -f Dockerfile -t pleroma:run
runvars=$runvars"run"
fi
podman run $runmode \
--name pleroma-web \
--pod pleroma-pod \
-v ./uploads:/var/lib/pleroma/uploads \
-v ./static:/var/lib/pleroma/static \
-v ./config.exs:/etc/pleroma/config.exs:ro \
-e DOMAIN=example.tld \
-e INSTANCE_NAME=Pleroma \
-e ADMIN_EMAIL=admin@example.tld \
-e NOTIFY_EMAIL=notify@example.tld \
-e DB_USER=pleroma \
-e DB_PASS=CHANGEME \
-e DB_NAME=pleroma \
-e DB_HOST=localhost \
-e POSTGRES_HOST=localhost \
$runvars
if [[ $1 == "build-setup" ]]; then
podman exec pleroma-web /pleroma/bin/pleroma_ctl config migrate_to_db
fi
if [[ $1 == "gen-keypair" ]]; then
podman exec pleroma-web mix web_push.gen.keypair
fi

11
script_config.sh Normal file
View file

@ -0,0 +1,11 @@
#!/bin/bash
DATE=$(date +"%Y-%m-%d")
PG_USER=rebased
PG_PASS=rebased
PG_HOST=localhost
PG_NAME=rebased
REBASED_VER=develop
REBASED_IMG="rebased-$REBASED_VER-$DATE"
echo $REBASED_IMG