about ready to start testingabout ready to start testing

This commit is contained in:
Jeffrey Paul 2019-12-07 22:50:36 -08:00
parent bf6a0dc199
commit c7b081f5b9
10 changed files with 107 additions and 5 deletions

View File

@ -3,6 +3,15 @@ FROM phusion/baseimage:0.11
# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]
ENV \
RUN_DB_MIGRATIONS=true \
SIDEKIQ_WORKERS=5 \
RAILS_SERVE_STATIC_FILES=true \
RAILS_ENV=production \
NODE_ENV=production \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/mastodon/app/bin
# install os prereq stuff to image
ADD prereqs.sh /tmp/prereqs.sh
RUN bash /tmp/prereqs.sh
@ -10,6 +19,8 @@ RUN bash /tmp/prereqs.sh
# install mastodon:
ADD install.sh /tmp/install.sh
WORKDIR /mastodon
ENV HOME /mastodon
RUN chpst -u mastodon:mastodon bash /tmp/install.sh
ADD ./rootfs /
@ -19,3 +30,6 @@ RUN chmod +x /usr/local/bin/* /etc/service/*/run
VOLUME /state
EXPOSE 3000 4000
LABEL maintainer="Jeffrey Paul <sneak@sneak.berlin>" \
description="Your self-hosted, globally interconnected microblogging community"

View File

@ -1,4 +1,9 @@
NAME := sneak/mastodon
default: build
build:
docker build -t sneak/mastodon .
docker build -t $(NAME) .
run:
docker run -ti $(NAME)

View File

@ -1,6 +1,5 @@
#!/bin/bash
export HOME="/mastodon"
export PATH="$HOME/.rbenv/bin:$PATH"
export RUBY_CONFIGURE_OPTS="--with-jemalloc"
@ -10,8 +9,8 @@ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> $HOME/.bashrc
echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
eval "$(rbenv init -)"
rbenv install 2.6.1
rbenv global 2.6.1
rbenv install 2.6.5
rbenv global 2.6.5
gem update --system
gem install bundler --no-document
@ -20,7 +19,12 @@ cd /mastodon/app
# v3.0.1:
git checkout c4118ba71ba31e408c02d289e111326ccc6f6aa2
bundle config build.nokogiri --use-system-libraries
bundle install \
-j$(getconf _NPROCESSORS_ONLN) \
--deployment --without development test
yarn install --pure-lockfile
yarn install --pure-lockfile --ignore-engines
OTP_SECRET=precompile_placeholder \
SECRET_KEY_BASE=precompile_placeholder \
bundle exec rails assets:precompile

View File

@ -0,0 +1,5 @@
#!/bin/bash
echo "postfix starting..."
exec /usr/lib/postfix/master

View File

@ -0,0 +1,8 @@
#!/bin/bash
echo "postgres starting..."
mkdir -p /state/db
chown mastodon:mastodon /state/db
exec chpst -u mastodon:mastodon /usr/lib/postgresql/bin/postmaster \
-D /state/db 2>&1

View File

@ -0,0 +1,5 @@
#!/bin/bash
mkdir -p /state/redis
chown mastodon:mastodon /state/redis
exec chpst -u mastodon:mastodon /usr/bin/redis-server /etc/redis/redis.conf

View File

@ -0,0 +1,14 @@
#!/bin/bash
sleep 2
while [[ -e /state/.starting ]]; do
sleep 1
done
echo "sidekiq starting..."
cd /mastodon/app
exec \
envdir /state/envdir \
chpst -u mastodon:mastodon \
bash -c "bundle exec sidekiq -c $SIDEKIQ_WORKERS -q default -q push -q pull -q mailers"

View File

@ -0,0 +1,25 @@
#!/bin/bash
touch /state/.starting
echo "mastodon-startup starting up..."
if [[ ! -d /state/envdir ]]; then
mkdir -p /state/envdir
chown mastodon:mastodon /state/envdir
fi
if [[ ! -e /state/envdir/HOME ]]; then
echo "/mastodon" > /state/envdir/HOME
fi
cd /mastodon/app
if [ "$RUN_DB_MIGRATIONS" == "true" ]; then
echo "Running database migrations..."
envdir /state/envdir chpst -u mastodon:mastodon bash -c "bundle exec rake db:migrate"
fi
rm /state/.starting
while true ; do
sleep 86400
done

View File

@ -0,0 +1,11 @@
#!/bin/bash
sleep 2
while [[ -e /state/.starting ]]; do
sleep 1
done
echo "streaming starting..."
cd /mastodon/app
exec envdir /state/envdir chpst -u mastodon:mastodon bash -c "npm run start"

View File

@ -0,0 +1,11 @@
#!/bin/bash
sleep 2
while [[ -e /state/.starting ]]; do
sleep 1
done
echo "web starting..."
cd /mastodon/app
exec envdir /state/envdir chpst -u mastodon:mastodon bash -c "bundle exec puma -C config/puma.rb"