philomena/docker/app/run-development
Nighty 194b2686f6
Migrate to OpenSearch (#186)
* Migrate to OpenSearch

* opensearch security is stupid

* forgor

---------

Co-authored-by: byte[] <byteslice@airmail.cc>
2024-05-24 22:58:18 +02:00

58 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env sh
# Create S3 dirs
mkdir -p /srv/philomena/priv/static/system/images/thumbs
mkdir -p /srv/philomena/priv/s3/philomena
ln -sf /srv/philomena/priv/static/system/images/thumbs /srv/philomena/priv/s3/philomena/images
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/adverts
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/avatars
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/badges
ln -sf /srv/philomena/priv/static/system/images /srv/philomena/priv/s3/philomena/tags
# For compatibility with musl libc
export CARGO_FEATURE_DISABLE_INITIAL_EXEC_TLS=1
export CARGO_HOME=/srv/philomena/.cargo
background() {
while :; do
mix run -e 'Philomena.Release.update_channels()'
mix run -e 'Philomena.Release.verify_artist_links()'
mix run -e 'Philomena.Release.update_stats()'
mix run -e 'Philomena.Release.clean_moderation_logs()'
mix run -e 'Philomena.Release.generate_autocomplete()'
sleep 300
done
}
# Always install assets
(
cd /srv/philomena/assets
npm install
)
# Always install mix dependencies
(cd /srv/philomena && mix deps.get)
# Sleep to allow OpenSearch to finish initializing
# if it's not done doing whatever it does yet
echo -n "Waiting for OpenSearch"
until wget --no-check-certificate -qO - http://opensearch:9200; do
echo -n "."
sleep 2
done
echo
# Try to create the database if it doesn't exist yet
createdb -h postgres -U postgres philomena_dev && mix ecto.setup_dev && mix reindex_all
# Explicitly compile deps to avoid racing
mix compile
# Run background jobs
background &
# Run the application
START_WORKER=true exec mix phx.server