notes/multipass.md

3.2 KiB

mutlipass - ubuntu vm's from canonical

snap install multipass --classic (apparently this option is required and allows the snap to violate it's sandbox??)

https://multipass.run/

launch an instance:

  • multipass launch --name ubuntu-lts
  • multipass stop ubuntu-lts
  • multipass delete ubuntu-lts-custom
  • multipass purge
  • multipass find

you have to sudo multipass shell to get a sudo-able shell

setup

sudo apt update
sudo apt upgrade
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -   
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt -y install postgresql-12 postgresql-client-12

sudo apt install nginx
sudo apt install nodejs
sudo apt install redis
sudo apt install npm
sudo npm install -g n
n lts

sudo su root
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
exit

sudo apt update

apt install -y \
  imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \
  g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \
  bison build-essential libssl-dev libyaml-dev libreadline6-dev \
  zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev \
  nginx redis-server redis-tools postgresql postgresql-contrib \
  certbot python-certbot-nginx yarn libidn11-dev libicu-dev libjemalloc-dev

install mastodon

adduser --disabled-login mastodon
sudo su - mastodon
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec bash
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.5
rbenv global 2.6.5
gem update --system
gem install bundler --no-document
exit

sudo -u postgres psql
CREATE USER mastodon CREATEDB;
\q

git clone https://github.com/tootsuite/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)


bundle install \
  -j$(getconf _NPROCESSORS_ONLN) \
  --deployment --without development test
yarn install --pure-lockfile

need to set database credentials before the env file is built

sudo su postgres
psql
alter role mastodon password 'mastodon';
\q

sudo vim //etc/redis/redis.conf
requirepass password
RAILS_ENV=production bundle exec rake mastodon:setup

this will prompt a bunch of setting, after a while mail from localhost = no this will prompt smtp setup


compilation failed, complained about memory

setup nginx files:

cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon


then you have to replace example.com with a target domain in the nginx files
using vim -> `:%s/example.com/hptrow.me`


copy sevice files:

cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/


setup load services

sudo systemctl daemon-reload sudo systemctl start mastodon-web mastodon-sidekiq mastodon-streaming sudo systemctl enable mastodon-*