Browse Source

general updates, wait until IP is pointing to instance before starting

master
Pasture Pastureson 4 months ago
parent
commit
a1376795fc
2 changed files with 23 additions and 5 deletions
  1. +1
    -2
      Dockerfile
  2. +22
    -3
      docker-entrypoint.sh

+ 1
- 2
Dockerfile View File

@ -29,7 +29,7 @@ ARG HOME=/opt/pleroma
ARG DATA=/var/lib/pleroma
RUN apt-get update &&\
apt-get install -y --no-install-recommends imagemagick libmagic-dev ffmpeg libimage-exiftool-perl libncurses5 postgresql-client curl unzip ca-certificates &&\
apt-get install -y --no-install-recommends imagemagick libmagic-dev ffmpeg libimage-exiftool-perl libncurses5 postgresql-client curl unzip ca-certificates jq &&\
adduser --system --shell /bin/false --home ${HOME} pleroma &&\
mkdir -p ${DATA}/uploads &&\
mkdir -p ${DATA}/static &&\
@ -109,7 +109,6 @@ RUN chmod 755 /run/postgres.sh
VOLUME "/caddy"
VOLUME "/var/lib/postgresql/14/pleroma"
VOLUME "${DATA}/static"
VOLUME "${DATA}/uploads"
EXPOSE 80


+ 22
- 3
docker-entrypoint.sh View File

@ -2,6 +2,17 @@
set -e
if [ -n "$IP" ]; then
echo "Will check name resolution."
resolv=$(curl "https://dns.google/resolve?name=$DOMAIN" | jq -c -r .Answer[0].data)
while [ "$resolv" != "$IP" ]; do
echo "Waiting for name to resolve properly (want $IP for $DOMAIN, got $resolv)..."
sleep 60
resolv="$(curl 'https://dns.google/resolve?name=$DOMAIN' | jq -c -r .Answer[0].data)"
done
echo "$DOMAIN resolves to $resolv"
fi
export DATABASE_URL="postgres://pleroma:bleromer@localhost:5433/pleroma"
echo "-- Setting up PostgreSQL..."
@ -24,17 +35,25 @@ gosu caddy caddy start --config /etc/Caddyfile
echo "-- Running migrations..."
gosu pleroma sh -c "/opt/pleroma/bin/pleroma_ctl migrate"
if [ ! -f "/var/lib/pleroma/static/.migrated" ]; then
if [ ! -f "/var/lib/pleroma/uploads/.migrated" ]; then
echo "-- Transferring config to database"
gosu pleroma sh -c "/opt/pleroma/bin/pleroma start" &
sleep 10
gosu pleroma sh -c "/opt/pleroma/bin/pleroma_ctl config migrate_to_db"
if [ -n "ADMIN" ]; then
echo "-- Creating admin user"
set +e
gosu pleroma sh -c "/opt/pleroma/bin/pleroma_ctl user new $ADMIN admin@$DOMAIN --password \"$PASSWORD\" --admin -y"
set -e
fi
gosu pleroma sh -c "/opt/pleroma/bin/pleroma stop" &
echo "migrated" > /var/lib/pleroma/static/.migrated
echo "migrated" > /var/lib/pleroma/uploads/.migrated
sleep 10
else
echo "-- Already migrated config to DB. Skipping."
fi
echo "-- Starting!"
gosu pleroma sh -c "/opt/pleroma/bin/pleroma start"
gosu pleroma sh -c "/opt/pleroma/bin/pleroma start"

Loading…
Cancel
Save