Compare commits

...

6 Commits

Author SHA1 Message Date
Rin 8f59e1a853
Fix numbering <_< 2022-11-21 21:27:58 +11:00
Rin 5928dec1f5
Reduce .env file to minimal config 2022-11-21 21:06:35 +11:00
Rin 5f2752d57b
update gitignore to ignore the pg db we created 2022-11-21 19:33:31 +11:00
Rin 31978dd1b2
use local pg cluster instead 2022-11-21 19:31:46 +11:00
Rin e77d1821a7
fix typo 2022-11-21 18:11:49 +11:00
Rin 3414cfbd90
Add SETUP instructions 2022-11-21 17:43:06 +11:00
3 changed files with 87 additions and 0 deletions

4
.env.dev Normal file
View File

@ -0,0 +1,4 @@
LOCAL_DOMAIN=localhost
DB_HOST=/var/run/postgresql
DB_USER=mastodon
DB_NAME=mastodon_development

3
.gitignore vendored
View File

@ -12,6 +12,9 @@
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore the dev postgres db we created.
/data/postgres15/*
# Ignore all logfiles and tempfiles.
.eslintcache
/log/*

80
SETUP.md Normal file
View File

@ -0,0 +1,80 @@
# Setting up a dev environment
## Assumptions
You have a package manager, and your system is systemd-based.
## Prerequisites
## Nodejs
Install nodejs via your package manager. We used v19.1.0 for this setup.
## Ruby
Install ruby via your package manager of choice.
## Ruby Extras
Your distro may package `bundle` and `irb` in separate packages (Arch does). If they are, install them too.
On Arch these are `ruby-bundler` and `ruby-irb`.
## PostGreSQL
Install postgres via your package manager.
## Redis
Install redis via your package manager.
Enable and start the default `redis.service`
## Setting up the Environment
In the following instructions, replace USER with your *nix user name.
1. Add yourself to the postgres group with `sudo usermod -a -G postgres USER`. You'll need to log out and back in to
update your groups.
2. Run `sudo mkdir /run/postgresql` to create said folder if it doesn't exist.
3. Run `sudo chown postgres:postgres /run/postgresql` to change the owner to postgres.
4. Run `sudo chmod g+w /run/postgresql` to allow `postgres` group members to write to the folder.
5. Navigate to the root of this repo.
6. Set up a local DB cluster with `pg_ctl -D data/postgres15 initdb -o '-U mastodon --auth-host=trust'`.
7. Run it with `pg_ctl -D data/postgres15 start`.
8. Run `bundle config set --local path 'vendor/bundle`. This will store the all the ruby gems locally so that we can
avoid interfering with system config.
9. Run `bundle install`.
10. Run `yarn install`.
11. Run `export $(grep -v '^#' .env.dev | xargs)` to source in our dev vars. You may want to alias this.
12. Run `bundle exec rake db:setup`. If this fails, you can use `bundle exec rake db:reset` to forcibly regenerate it.
## Running Mastodon
1. To make our lives easier, we'll use `foreman` to run the site, so use `gem install foreman`.
2. Run `export RAILS_ENV=development` and `export NODE_ENV=development`.
a. Put these in your shell's .rc, or a script you can source if you want to skip this step in the future.
3. Run `bundle exec rake assets:precompile`.
a. If this explodes, complaining about `Hash`, you'll need to `export NODE_OPTIONS=--openssl-legacy-provider`. Same
deal as the above.
b. After doing this, you will need to `bundle exec rake assets:clobber` and then re-run
`bundle exec rake assets:precompile`.
4. Run `foreman start`
# Updates/Troubleshooting
## RubyVM/DebugInspector Issues
Still unable to fix. Circumvent by removing `better_errors` and `binding_of_caller` from Gemfile.
Happy to troubleshoot with someone better with Ruby than us >_<'/.
## Webpack Issues
If Webpack compalins about being unable to find some assets or locales:
1. yarn add webpack
2. git restore package.json yarn.lock
3. yarn install
Then re-run `foreman`. No. We have no idea why this worked.
If the above instructions don't work, please contact @Rin here, or @tammy@social.treehouse.systems.