move database ready check into init container

This commit is contained in:
red 2025-03-06 23:40:47 -05:00
parent 64dc13b3ad
commit ea4bd5e94d
2 changed files with 12 additions and 3 deletions

View file

@ -45,6 +45,17 @@ spec:
spec: spec:
imagePullSecrets: imagePullSecrets:
- name: registry-credentials - name: registry-credentials
initContainers:
- name: pleroma-database-wait
image: cr.forge.lan/darkdork-dev/pleroma
command: ["sh", "-c", "while ! pg_isready -U ${DB_USER} -d postgres://${DB_HOST}:${DB_PORT}/${DB_NAME} -t 1; do sleep 1s; done;"]
env:
- name: DB_HOST
value: postgres
- name: DB_NAME
value: pleroma
- name: DB_USER
value: pleroma
containers: containers:
- name: pleroma - name: pleroma
image: cr.forge.lan/darkdork-dev/pleroma image: cr.forge.lan/darkdork-dev/pleroma

View file

@ -2,12 +2,10 @@
set -e set -e
# Move the files that were built into the image into the directory they will be served from
mkdir -p ${DATA}/uploads && mkdir -p ${DATA}/static mkdir -p ${DATA}/uploads && mkdir -p ${DATA}/static
cp -rf /static-files/* ${DATA}/static cp -rf /static-files/* ${DATA}/static
echo "-- Waiting for database..."
while ! pg_isready -U ${DB_USER:-pleroma} -d postgres://${DB_HOST:-db}:${DB_PORT:-5432}/${DB_NAME:-pleroma} -t 1; do sleep 1s; done;
echo $DB_PASSWORD
echo "-- Running migrations..." echo "-- Running migrations..."
$HOME/bin/pleroma_ctl migrate $HOME/bin/pleroma_ctl migrate