fix some bugs

This commit is contained in:
Jeffrey Paul 2019-12-09 05:11:52 -08:00
parent 53f3538cda
commit 2862faf676
4 changed files with 37 additions and 10 deletions

View File

@ -3,6 +3,11 @@ FROM phusion/baseimage:0.11
# Use baseimage-docker's init system. # Use baseimage-docker's init system.
CMD ["/sbin/my_init"] CMD ["/sbin/my_init"]
# make some SSH keys that will never get used just so that
# the container doesn't generate new ones each and every boot
# (sshd is not enabled in the container)
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
ENV \ ENV \
RUN_DB_MIGRATIONS=true \ RUN_DB_MIGRATIONS=true \
SIDEKIQ_WORKERS=5 \ SIDEKIQ_WORKERS=5 \

View File

@ -35,11 +35,16 @@ Mastodon instance.
* `RUN_DB_MIGRATIONS` (default: `true`, set to empty string `""` to disable) * `RUN_DB_MIGRATIONS` (default: `true`, set to empty string `""` to disable)
* `SIDEKIQ_WORKERS`: (default: `5`) * `SIDEKIQ_WORKERS`: (default: `5`)
* others: https://github.com/tootsuite/mastodon/blob/master/.env.production.sample * others: https://github.com/tootsuite/mastodon/blob/master/.env.production.sample
# Volumes # Volumes
* `/state` - everything lives in here, db, redis, static files, logs, * `/state` - everything lives in here, db, redis, static files, logs,
everything everything
Note that `/state/envdir` is an environment-variable-defining directory that
is used for all service invocations, so you can set environment settings
here for all processes without restarting the docker container.
# Ports # Ports
* 3000: mastodon web (no tls, do that elsewhere) * 3000: mastodon web (no tls, do that elsewhere)
@ -75,3 +80,13 @@ Google.)
"imageName": "sneak/mastodon:v3.0.1" "imageName": "sneak/mastodon:v3.0.1"
} }
``` ```
# After First Run
```
# docker exec -ti <container name> /bin/bash
root@c81a376bf546:~/app# su - mastodon
mastodon@c81a376bf546:~$ cd app
mastodon@c81a376bf546:~/app$ RAILS_ENV=production envdir /state/envdir bin/tootctl accounts create <newusername> --email <your email> --confirmed --role admin
```

View File

@ -9,19 +9,18 @@ if [[ ! -d /state/envdir ]]; then
chown mastodon:mastodon /state/envdir chown mastodon:mastodon /state/envdir
fi fi
if [[ ! -e /state/envdir/WEB_DOMAIN ]]; then if [[ -z "$WEB_DOMAIN" ]]; then
if [[ -n "$WEB_DOMAIN" ]]; then WEB_DOMAIN="$(hostname --fqdn)"
echo "$WEB_DOMAIN" > /state/envdir/WEB_DOMAIN
else
hostname --fqdn > /state/envdir/WEB_DOMAIN
fi
chown mastodon:mastodon /state/envdir/*
fi fi
cat /etc/postfix/main.cf | grep -v '^myhostname' > /etc/postfix/main.new if [[ -e /state/envdir/WEB_DOMAIN ]]; then
WEB_DOMAIN="$(cat /state/envdir/WEB_DOMAIN)"
fi
cat /etc/postfix/main.cf | grep -v '^myhostname' | grep -v '^myorigin' > /etc/postfix/main.new
rm /etc/postfix/main.cf rm /etc/postfix/main.cf
echo "myhostname = $(cat /state/envdir/WEB_DOMAIN)" >> /etc/postfix/main.cf echo "myhostname = $WEB_DOMAIN" >> /etc/postfix/main.cf
echo "myorigin = $(cat /state/envdir/WEB_DOMAIN)" >> /etc/postfix/main.cf echo "myorigin = $WEB_DOMAIN" >> /etc/postfix/main.cf
cat /etc/postfix/main.new >> /etc/postfix/main.cf cat /etc/postfix/main.new >> /etc/postfix/main.cf
rm /etc/postfix/main.new rm /etc/postfix/main.new

View File

@ -24,6 +24,14 @@ if [[ ! -d /state/db ]]; then
chmod go-rwx /state/db/data chmod go-rwx /state/db/data
fi fi
function shutdown()
{
echo "Shutting down PostgreSQL"
pkill postgres
}
trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
exec \ exec \
chpst -u mastodon:mastodon \ chpst -u mastodon:mastodon \
/usr/lib/postgresql/10/bin/postmaster -D /state/db 2>&1 /usr/lib/postgresql/10/bin/postmaster -D /state/db 2>&1