scripts/lech/docker/mastodon.sh

109 lines
3.0 KiB
Bash
Raw Normal View History

2023-09-05 11:40:31 -04:00
#!/bin/bash
set -e
2024-06-01 08:52:01 -04:00
TRUSTED_PROXY_IP=172.0.0.0/8
2023-09-05 11:40:31 -04:00
LOCAL_DOMAIN=social.bigcavemaps.com
REDIS_HOST=mastodon-redis
REDIS_PORT=6379
DB_HOST=mastodon-pg
DB_USER=mastodon
DB_NAME=mastodon_production
DB_PASS=mastodon
DB_PORT=5432
up () {
docker run \
--detach \
--name mastodon-web \
--restart unless-stopped \
2024-09-02 16:53:27 -04:00
--env-file $HOME/scripts-private/lech/mastodon.env \
2023-09-05 11:40:31 -04:00
--env TRUSTED_PROXY_IP=$TRUSTED_PROXY_IP \
--env LOCAL_DOMAIN=$LOCAL_DOMAIN \
--env REDIS_HOST=$REDIS_HOST \
--env REDIS_PORT=$PORT \
--env DB_HOST=$DB_HOST \
--env DB_USER=$DB_USER \
--env DB_NAME=$DB_NAME \
--env DB_PASS=$DB_PASS \
--env DB_PORT=$DB_PORT \
2023-09-07 21:08:48 -04:00
--volume /mammoth/mastodon/public/system:/mastodon/public/system:rw \
2023-09-05 11:40:31 -04:00
--network pew-net \
ghcr.io/mastodon/mastodon:v4.1 bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
docker run \
--detach \
--name mastodon-streaming \
--restart unless-stopped \
2024-09-02 16:53:27 -04:00
--env-file $HOME/scripts-private/lech/mastodon.env \
2023-09-05 11:40:31 -04:00
--env TRUSTED_PROXY_IP=$TRUSTED_PROXY_IP \
--env LOCAL_DOMAIN=$LOCAL_DOMAIN \
--env REDIS_HOST=$REDIS_HOST \
--env REDIS_PORT=$PORT \
--env DB_HOST=$DB_HOST \
--env DB_USER=$DB_USER \
--env DB_NAME=$DB_NAME \
--env DB_PASS=$DB_PASS \
--env DB_PORT=$DB_PORT \
--network pew-net \
ghcr.io/mastodon/mastodon:v4.1 node ./streaming
docker run \
--detach \
--name mastodon-sidekiq \
--restart unless-stopped \
2024-09-02 16:53:27 -04:00
--env-file $HOME/scripts-private/lech/mastodon.env \
2023-09-05 11:40:31 -04:00
--env TRUSTED_PROXY_IP=$TRUSTED_PROXY_IP \
--env LOCAL_DOMAIN=$LOCAL_DOMAIN \
--env REDIS_HOST=$REDIS_HOST \
--env REDIS_PORT=$PORT \
--env DB_HOST=$DB_HOST \
--env DB_USER=$DB_USER \
--env DB_NAME=$DB_NAME \
--env DB_PASS=$DB_PASS \
--env DB_PORT=$DB_PORT \
2023-09-07 21:08:48 -04:00
--volume /mammoth/mastodon/public/system:/mastodon/public/system:rw \
2023-09-05 11:40:31 -04:00
--network pew-net \
ghcr.io/mastodon/mastodon:v4.1 bundle exec sidekiq
# may have to run db:migrate if things don't work right away
docker run \
--detach \
--name mastodon-pg \
--restart unless-stopped \
--env POSTGRES_HOST_AUTH_METHOD=trust \
--env POSTGRES_USER=$DB_USER \
--env POSTGRES_DB=$DB_NAME \
--env POSTGRES_PASSWORD=$DB_PASS \
2023-09-07 21:08:48 -04:00
--volume /mammoth/mastodon/postgres/data:/var/lib/postgresql/data:rw \
2023-09-05 11:40:31 -04:00
--network pew-net \
docker.io/postgres:14-alpine
docker run \
--detach \
--name mastodon-redis \
--restart unless-stopped \
2023-09-07 21:08:48 -04:00
--volume /mammoth/mastodon/redis/data:/data:rw \
2023-09-05 11:40:31 -04:00
--network pew-net \
docker.io/redis:7-alpine
}
down () {
docker stop mastodon-web || true
docker rm mastodon-web || true
docker stop mastodon-streaming || true
docker rm mastodon-streaming || true
docker stop mastodon-sidekiq || true
docker rm mastodon-sidekiq || true
docker stop mastodon-pg || true
docker rm mastodon-pg || true
docker stop mastodon-redis || true
docker rm mastodon-redis || true
}
logs () {
docker logs --follow mastodon
}
$@