Skip to content
This repository was archived by the owner on Aug 31, 2025. It is now read-only.

Commit aa2c625

Browse files
committed
Add documentation to repository
1 parent 1b86fb3 commit aa2c625

File tree

4 files changed

+332
-2
lines changed

4 files changed

+332
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ the timeline and to ask their followers interesting questions.
1414
## Installation
1515

1616
You can find all the installation instructions needed for a local/production
17-
setup of Retrospring in the [Wiki](https://github.com/Retrospring/retrospring/wiki/Setup).
17+
setup of Retrospring in the [documentation](/docs/setup/source.md).
1818

1919
## Contributing
2020

2121
Retrospring is **free, open-source software** licensed under **AGPLv3**.
2222

2323
Our guidelines and general information about how you can help us
24-
improving Retrospring can be found in the [CONTRIBUTING.md](https://github.com/Retrospring/retrospring/blob/master/.github/CONTRIBUTING.md) file.
24+
improving Retrospring can be found in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md) file.
2525

2626
## Licence
2727

docs/setup/first-steps.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Now visit your newly created instance at localhost:3000 or the configured hostname and register a new account.
2+
3+
### Administrator
4+
5+
To give yourself administrator permissions there's two supported ways:
6+
7+
**Rake**
8+
9+
```shell
10+
RAILS_ENV=... bundle exec rake 'justask:admin[your_username]'
11+
```
12+
13+
`your_username` being your username and `RAILS_ENV` being set to either `development` or `production`
14+
15+
_You can find more rake tasks to use [here](/docs/setup/rake-tasks.md)!_
16+
17+
**Rails Console**
18+
19+
```shell
20+
RAILS_ENV=... bundle exec rails c
21+
> @user = User.first
22+
> @user.add_role :administrator
23+
> @user.save!
24+
```

docs/setup/rake-tasks.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Rake Tasks
2+
3+
Different backend tasks affecting users or the database, besides `admin/deadmin` every task can be done on the web interface itself if you visit an users profile.
4+
5+
## User-related Tasks
6+
7+
**Adding/Removing Admin Status:**
8+
9+
RAILS_ENV=production bundle exec rake 'justask:admin[your_username]'
10+
RAILS_ENV=production bundle exec rake 'justask:deadmin[get_rekt]'
11+
12+
**Adding/Removing Moderator Status:**
13+
14+
RAILS_ENV=production bundle exec rake 'justask:mod[someone_else]'
15+
RAILS_ENV=production bundle exec rake 'justask:demod[someone_else]'
16+

docs/setup/source.md

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
This page details the steps required to set up a production environment from source.
2+
3+
> [!NOTE]
4+
> This documentation has been heavily adopted from [Mastodons 'Installing from source' documentation](https://docs.joinmastodon.org/admin/install/)
5+
6+
## Pre-requisites
7+
8+
* A server running **Ubuntu 24.04** or **Debian 12** that you have root access to
9+
* A domain name (or subdomain) for your Retrospring site, like `example.com`
10+
* A mail delivery service or an SMTP server
11+
12+
### System repositories
13+
14+
Make sure curl, wget, gnupg, apt-transport-https, lsb-release and ca-certificates are installed first:
15+
16+
```shell
17+
apt install -y curl wget gnupg apt-transport-https lsb-release ca-certificates
18+
```
19+
20+
#### Node.js
21+
22+
```shell
23+
mkdir -p /etc/apt/keyrings && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
24+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
25+
```
26+
27+
Retrospring uses Yarn as a package manager:
28+
29+
```shell
30+
npm install -g yarn
31+
```
32+
33+
### System packages
34+
35+
```shell
36+
apt-get install -y --no-install-recommends build-essential libpq-dev postgresql-client libxml2-dev libxslt1-dev libmagickwand-dev imagemagick libidn11-dev libicu-dev libjemalloc-dev libyaml-dev libreadline-dev libssl-dev libjemalloc-dev redis-server redis-tools
37+
```
38+
39+
### Installing Ruby
40+
41+
We will use rbenv to manage Ruby versions as it simplifies obtaining the correct versions and updating them when new releases are available. Since rbenv needs to be installed for an individual Linux user, we must first create the user account under which Retrospring will run:
42+
43+
```shell
44+
adduser --disabled-login retrospring
45+
usermod -s /bin/bash retrospring
46+
```
47+
48+
We can then switch to the user:
49+
50+
```shell
51+
su - retrospring
52+
```
53+
54+
And proceed to install rbenv and rbenv-build:
55+
56+
```bash
57+
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
58+
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
59+
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
60+
exec bash
61+
```
62+
```bash
63+
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
64+
```
65+
66+
Once this is done, we can install the correct Ruby version:
67+
68+
```shell
69+
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.3
70+
rbenv global 3.2.3
71+
```
72+
73+
We’ll also need to install the bundler:
74+
75+
```shell
76+
gem install bundler --no-document
77+
```
78+
79+
Return to the root user:
80+
81+
```shell
82+
exit
83+
```
84+
85+
## Setup
86+
87+
### Setting up PostgreSQL
88+
89+
#### Performance configuration (optional)
90+
91+
For optimal performance, you may use [pgTune](https://pgtune.leopard.in.ua/#/) to generate an appropriate configuration and edit values in `/etc/postgresql/16/main/postgresql.conf` before restarting PostgreSQL with `systemctl restart postgresql`
92+
93+
#### Creating a user
94+
95+
You will need to create a PostgreSQL user that Retrospring could use. It is easiest to go with “ident” authentication in a simple setup, i.e. the PostgreSQL user does not have a separate password and can be used by the Linux user with the same username.
96+
97+
Open the prompt:
98+
99+
```shell
100+
sudo -u postgres psql
101+
```
102+
103+
In the prompt, execute:
104+
105+
```sql
106+
CREATE USER retrospring CREATEDB;
107+
CREATE DATABASE retrospring_production OWNER retrospring;
108+
\q
109+
```
110+
111+
Done!
112+
113+
### Setting up nginx
114+
115+
Copy the configuration template for nginx from the Retrospring directory:
116+
117+
```bash
118+
cp /home/retrospring/retrospring/docs/nginx.conf /etc/nginx/sites-available/retrospring
119+
ln -s /etc/nginx/sites-available/retrospring /etc/nginx/sites-enabled/retrospring
120+
rm /etc/nginx/sites-enabled/default
121+
```
122+
123+
Then edit `/etc/nginx/sites-available/retrospring` and follow the comments and adjusts domains and paths according to your setup.
124+
125+
Reload nginx for the changes to take effect:
126+
127+
```bash
128+
systemctl reload nginx
129+
```
130+
131+
### Setting up Retrospring
132+
133+
It is time to download the Retrospring code. Switch to the retrospring user:
134+
135+
```shell
136+
su - retrospring
137+
```
138+
139+
#### Checking out the code
140+
141+
Use git to download the latest stable release of Retrospring:
142+
143+
```shell
144+
git clone https://github.com/Retrospring/retrospring.git && cd retrospring
145+
```
146+
147+
Visit [the latest releases page](https://github.com/retrospring/retrospring/releases/latest) and check it out (ex. `2024.0811.1`)
148+
149+
```shell
150+
git checkout 2024.0811.01
151+
```
152+
153+
#### Installing dependencies
154+
155+
Now to install Ruby and JavaScript dependencies:
156+
157+
```shell
158+
bundle install --deployment --without development test mysql
159+
yarn install --frozen-lockfile
160+
```
161+
162+
#### Configuring Retrospring
163+
164+
##### Database configuration
165+
166+
You can either configure Retrosprings database connection via environment variables:
167+
168+
```shell
169+
export DATABASE_URL=postgres://[username]:[password]@[host]/[dbname]?pool=25
170+
```
171+
172+
...or with copying the `config/database.yml.postgres` to `config/database.yml` and adjusting its contents:
173+
174+
```shell
175+
cp config/database.yml.postgres config/database.yml
176+
$EDITOR config/database.yml
177+
```
178+
179+
##### Application configuration
180+
181+
Copy the configuration file `config/justask.yml.example` to `config/justask.yml` and adjust its contents:
182+
183+
```
184+
cp config/justask.yml.example config/justask.yml
185+
$EDITOR config/justask.yml
186+
```
187+
##### SMTP configuration
188+
189+
It is recommended to read up on the chapter [Action Mailer configuration](https://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration) from the Ruby on Rails guides.
190+
191+
E-Mail sending configuration is currently done via environment variables, the following ones are available:
192+
193+
| Rails `:smtp_settings` key | Retrospring environent variable |
194+
|----------------------------|---------------------------------|
195+
| `:address` | `SMTP_SERVER` |
196+
| `:port` | `SMTP_PORT` |
197+
| `:user_name` | `SMTP_LOGIN` |
198+
| `:password` | `SMTP_PASSWORD` |
199+
| `:domain` | `SMTP_DOMAIN` (or `LOCAL_DOMAIN` as fallback) |
200+
| `:authentication` | `SMTP_AUTH_METHOD`
201+
| `:ca_file` | `SMTP_CA_FILE` (`/etc/ssl/certs/ca-certificates.crt` as default) |
202+
| `:openssl_verify_mode` | `SMTP_OPENSSL_VERIFY_MODE` |
203+
| `:enable_starttls` | `SMTP_ENABLE_STARTTLS` (`always`, `never` or `auto`) |
204+
| `:enable_starttls_auto` | `true` when `SMTP_ENABLE_STARTTLS` is set to `auto`, otherwise `false` |
205+
| `:tls` | `SMTP_TLS` (any value, or `true` enables this) |
206+
| `:ssl` | `SMTP_SSL` (any value, or `true` enables this) |
207+
208+
Additionally, you can configure the Action Mailer delivery method using `SMTP_DELIVERY_METHOD`, the default is `sendmail`.
209+
210+
#### Setup tasks
211+
212+
##### Generate secret key
213+
214+
This command creates a secret key used for encryption/hashing across the application:
215+
216+
```shell
217+
RAILS_ENV=production bundle exec rails credentials:edit
218+
```
219+
220+
> [!NOTE]
221+
> This command only needs to be run once per setup, the other setup tasks need to be run after each deployment.
222+
223+
##### Export locales
224+
225+
This exports the locales for use in JavaScript code:
226+
227+
```shell
228+
RAILS_ENV=production bundle exec i18n export
229+
```
230+
231+
##### Initialize the database
232+
233+
This command creates the database schema:
234+
235+
```shell
236+
RAILS_ENV=production bundle exec rake db:migrate
237+
```
238+
239+
##### Precompile assets
240+
241+
This command compiles all JavaScript/Stylesheet assets:
242+
243+
```shell
244+
RAILS_ENV=production bundle exec rake assets:precompile
245+
```
246+
247+
#### Running Retrospring
248+
249+
##### Manually
250+
251+
You can start Retrospring manually using `foreman`.
252+
253+
If it is not installed yet, install it using Bundler with:
254+
255+
```shell
256+
gem install foreman
257+
```
258+
259+
Then just start Retrospring using:
260+
```shell
261+
foreman start
262+
```
263+
264+
##### As systemd services
265+
266+
Copy the example Retrospring service files from the repository:
267+
268+
```shell
269+
cp /home/retrospring/retrospring/docs/systemd/retrospring-*.service /etc/systemd/system/
270+
```
271+
272+
If you deviated from the defaults at any point, check that the username and paths are correct:
273+
274+
```
275+
$EDITOR /etc/systemd/system/retrospring-*.service
276+
```
277+
278+
Finally, start and enable the new systemd services:
279+
```shell
280+
systemctl daemon-reload
281+
systemctl enable --now retrospring-web retrospring-sidekiq
282+
```
283+
284+
They will now automatically start at boot.
285+
286+
----
287+
288+
You should now be able to visit your configured domain and see the Retrospring homepage!
289+
290+
Continue to [First Steps](/docs/setup/first-steps.md) for setting up an administrator account and more.

0 commit comments

Comments
 (0)