|
@@ -0,0 +1,258 @@
|
|
1
|
+# Requirements
|
|
2
|
+To run Aardbei, you will need a UNIX operating system, which basically means
|
|
3
|
+that you need to be running either macos or some flavour of Linux.
|
|
4
|
+Running on Windows might very well be possible, but I haven't tried it.
|
|
5
|
+
|
|
6
|
+The Ruby-version Aardbei uses is currently 2.3.3, and to ensure that the version
|
|
7
|
+is always available, and does not conflict with any system installation of some
|
|
8
|
+other Ruby version, the supported way to install it is by compiling from source
|
|
9
|
+using the platform-independent tool [rbenv], with two helper tools called
|
|
10
|
+[ruby-build] and [rbenv-vars].
|
|
11
|
+
|
|
12
|
+You will need the following tools installed in whatever way you like:
|
|
13
|
+- [Git]
|
|
14
|
+- Your distro's equivalent of `build-essential` (`make`, `gcc`, probably other
|
|
15
|
+ tools)
|
|
16
|
+- Development headers for `openssl`, `zlib` and `readline` (Ubuntu: `sudo apt
|
|
17
|
+ install libssl-dev zlib1g-dev libreadline-dev`)
|
|
18
|
+- Nodejs (`apt install nodejs`) for Javascript minifying.
|
|
19
|
+- In production: a working `postgresql` installation, with the development
|
|
20
|
+ headers for libpq (`apt install libpq-dev`). Other databases will probably
|
|
21
|
+ work because ActiveRecord should support it, but I'm using Postgres on my
|
|
22
|
+ own server, and haven't tested anything besides sqlite yet.
|
|
23
|
+- In development: libsqlite3 with development headers (`apt install
|
|
24
|
+ libsqlite3-dev`)
|
|
25
|
+
|
|
26
|
+# Installing rbenv, ruby-build, and rbenv-vars, and adding it to your shell
|
|
27
|
+
|
|
28
|
+## Installing rbenv
|
|
29
|
+To not depend on your distro's version of `rbenv` (if any), we install from
|
|
30
|
+rbenv's repository.
|
|
31
|
+
|
|
32
|
+Clone the rbenv repository to your home directory:
|
|
33
|
+
|
|
34
|
+```console
|
|
35
|
+$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
|
|
36
|
+```
|
|
37
|
+
|
|
38
|
+Try to compile the bash extension:
|
|
39
|
+
|
|
40
|
+```console
|
|
41
|
+$ cd ~/.rbenv; src/configure; make -C src; cd -
|
|
42
|
+```
|
|
43
|
+
|
|
44
|
+Add `rbenv` to your `$PATH` (note the double `>>`, a single `>` will trash your
|
|
45
|
+`.bashrc`!):
|
|
46
|
+
|
|
47
|
+```console
|
|
48
|
+$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
|
|
49
|
+$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
|
|
50
|
+$ source ~/.bashrc
|
|
51
|
+```
|
|
52
|
+
|
|
53
|
+## Installing ruby-build, compiling ruby
|
|
54
|
+`ruby-build` is a plugin for `rbenv` that provides automated compilation and
|
|
55
|
+installation of Ruby.
|
|
56
|
+
|
|
57
|
+Create the plugin-directory, and clone the repository to it:
|
|
58
|
+
|
|
59
|
+```console
|
|
60
|
+$ mkdir -p ~/.rbenv/plugins
|
|
61
|
+$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
|
|
62
|
+```
|
|
63
|
+
|
|
64
|
+Ensure you have the dependencies listed above installed (`build-essential` and
|
|
65
|
+the development headers for `openssl`, `libreadline` and `zlib`). Now start the
|
|
66
|
+compilation of Ruby (this will take a while and will not show a progress bar):
|
|
67
|
+
|
|
68
|
+```console
|
|
69
|
+$ rbenv install 2.3.3
|
|
70
|
+```
|
|
71
|
+
|
|
72
|
+If all is well, you will get some success message, if you have an error the
|
|
73
|
+script usually tells you what went wrong.
|
|
74
|
+
|
|
75
|
+## Installing rbenv-vars
|
|
76
|
+`rbenv-vars` is another plugin for `rbenv` that allows us to easily set
|
|
77
|
+environment variables by listing them in the file `.rbenv-vars`.
|
|
78
|
+
|
|
79
|
+Install it by cloning the repository:
|
|
80
|
+
|
|
81
|
+```console
|
|
82
|
+$ git clone https://github.com/rbenv/rbenv-vars.git ~/.rbenv/plugins/rbenv-vars
|
|
83
|
+```
|
|
84
|
+
|
|
85
|
+Copy the template `.rbenv-vars-sample` to `.rbenv-vars`, and set the
|
|
86
|
+environment to `production` or `development`, and the locale to `en` or `nl`,
|
|
87
|
+without quotes.
|
|
88
|
+
|
|
89
|
+```
|
|
90
|
+RAILS_ENV=development
|
|
91
|
+# ...
|
|
92
|
+AARDBEI_LOCALE=en
|
|
93
|
+```
|
|
94
|
+
|
|
95
|
+Set `AARDBEI_HOSTNAME` to the hostname your copy is going to run under (in development it's going to be `localhost:3000`:
|
|
96
|
+
|
|
97
|
+```
|
|
98
|
+AARDBEI_HOSTNAME=aardbei.maartenberg.nl
|
|
99
|
+```
|
|
100
|
+
|
|
101
|
+If you're planning to run in the production environment, but without a real webserver to serve your assets, set `RAILS_SERVE_STATIC_FILES=1`.
|
|
102
|
+
|
|
103
|
+Set `AARDBEI_PATH` to the full path of the cloned directory, like `AARDBEI_PATH=/home/aardbei/aardbei`.
|
|
104
|
+
|
|
105
|
+# Installing dependencies
|
|
106
|
+Aardbei's dependencies in Ruby are managed using Bundler. To install it, rbenv
|
|
107
|
+needs to know which version of Ruby we're using. This is stored in the file
|
|
108
|
+`.ruby-version`.
|
|
109
|
+
|
|
110
|
+Install bundler by moving to your cloned copy of Aardbei, and running:
|
|
111
|
+
|
|
112
|
+```console
|
|
113
|
+$ gem install bundler
|
|
114
|
+```
|
|
115
|
+
|
|
116
|
+Depending on your environment, run either:
|
|
117
|
+
|
|
118
|
+```console
|
|
119
|
+$ bundle install --without=production # in development
|
|
120
|
+$ bundle install --without='development test' # in production
|
|
121
|
+```
|
|
122
|
+
|
|
123
|
+If all went well, run `rbenv rehash` to add the new executables to your shell,
|
|
124
|
+and test that the installation worked by running `rails`. You should see some
|
|
125
|
+output listing the available subcommands.
|
|
126
|
+
|
|
127
|
+Open up your `.rbenv-vars` again, run the command `rails secret`, and set it as your `SECRET_KEY_BASE`:
|
|
128
|
+
|
|
129
|
+```console
|
|
130
|
+SECRET_KEY_BASE=a3a43b...
|
|
131
|
+```
|
|
132
|
+
|
|
133
|
+# Setting up the database
|
|
134
|
+
|
|
135
|
+## In development: SQLite
|
|
136
|
+When running in the development environment, the database is saved as a file in
|
|
137
|
+the `db` folder. To create it, and pre-fill some test data, run this command:
|
|
138
|
+
|
|
139
|
+```console
|
|
140
|
+$ RAILS_ENV=development rails db:setup
|
|
141
|
+```
|
|
142
|
+
|
|
143
|
+Note: __The test data currently includes a hardcoded admin user, change this if
|
|
144
|
+needed!__
|
|
145
|
+
|
|
146
|
+## In production: Postgresql
|
|
147
|
+If you're not already running Postgresql, install it using `sudo apt install
|
|
148
|
+postgresql-9.5`.
|
|
149
|
+
|
|
150
|
+Create a database and user with the following commands:
|
|
151
|
+
|
|
152
|
+```console
|
|
153
|
+$ sudo -u postgres psql
|
|
154
|
+postgres=# CREATE ROLE aardbei WITH LOGIN PASSWORD 'aardbei123';
|
|
155
|
+CREATE ROLE
|
|
156
|
+postgres=# CREATE DATABASE aardbei WITH OWNER = aardbei;
|
|
157
|
+CREATE DATABASE
|
|
158
|
+postgres=# GRANT ALL PRIVILEGES ON DATABASE aardbei TO aardbei;
|
|
159
|
+GRANT
|
|
160
|
+postgres=# \q
|
|
161
|
+```
|
|
162
|
+
|
|
163
|
+You will probably want to generate a real password for the database instead of
|
|
164
|
+`'aardbei123'`, this can be done by running `rails secret`.
|
|
165
|
+
|
|
166
|
+Fill in your database details in `.rbenv-vars`:
|
|
167
|
+
|
|
168
|
+```
|
|
169
|
+DB_NAME=aardbei
|
|
170
|
+DB_USER=aardbei
|
|
171
|
+DB_PASS=aardbei123
|
|
172
|
+```
|
|
173
|
+
|
|
174
|
+Now set up the database:
|
|
175
|
+
|
|
176
|
+```console
|
|
177
|
+$ rails db:setup
|
|
178
|
+```
|
|
179
|
+
|
|
180
|
+# Setting up email
|
|
181
|
+Aardbei needs to be able to email in order to send password reset links and
|
|
182
|
+reminders. Set the address for the `From:` field by setting:
|
|
183
|
+
|
|
184
|
+```
|
|
185
|
+MAIL_FROM_ADDRESS=aardbei@maartenberg.nl
|
|
186
|
+```
|
|
187
|
+
|
|
188
|
+Choose one of the below methods to deliver your mails:
|
|
189
|
+
|
|
190
|
+## Using Sendmail
|
|
191
|
+If your system already has working `sendmail`, set `MAIL_METHOD` to `sendmail`.
|
|
192
|
+
|
|
193
|
+```
|
|
194
|
+MAIL_METHOD=sendmail
|
|
195
|
+```
|
|
196
|
+
|
|
197
|
+## Using Mailgun
|
|
198
|
+If you have your own domain, you can use the free [Mailgun] tier to deliver your emails. In `.rbenv-vars`, set:
|
|
199
|
+
|
|
200
|
+```
|
|
201
|
+MAIL_METHOD=mailgun
|
|
202
|
+
|
|
203
|
+# ...
|
|
204
|
+
|
|
205
|
+MAILGUN_DOMAIN=your.domain.mg
|
|
206
|
+MAILGUN_API_KEY=key-abcdefpdftexexezip
|
|
207
|
+```
|
|
208
|
+
|
|
209
|
+## Using SMTP
|
|
210
|
+You can use a SMTP server. Set:
|
|
211
|
+
|
|
212
|
+```
|
|
213
|
+MAIL_METHOD=smtp
|
|
214
|
+
|
|
215
|
+SMTP_SERVER=email.example.com
|
|
216
|
+SMTP_USER=coolskeleton95
|
|
217
|
+SMTP_PASS=aardbei123
|
|
218
|
+```
|
|
219
|
+
|
|
220
|
+# Create an Admin person
|
|
221
|
+If you're not me, you'll want to create your own user. Run:
|
|
222
|
+
|
|
223
|
+```console
|
|
224
|
+$ rails console
|
|
225
|
+> p = Person.new
|
|
226
|
+> p.first_name = 'Maarten'
|
|
227
|
+> p.infix = 'van den'
|
|
228
|
+> p.last_name = 'Berg'
|
|
229
|
+> p.email = 'youremail@example.com'
|
|
230
|
+> p.is_admin = 1
|
|
231
|
+> p.save
|
|
232
|
+> exit
|
|
233
|
+```
|
|
234
|
+
|
|
235
|
+Note that this has not yet set a password for you: to do that, we need to run a server.
|
|
236
|
+
|
|
237
|
+# Running the server directly / in development mode
|
|
238
|
+To start the server, run the command `rails server`. Your terminal will block
|
|
239
|
+until you press Control-C. In addition to this, you will need to be running the
|
|
240
|
+jobs worker to be able to send emails. To start it, run (in another terminal or
|
|
241
|
+before starting the server) `bin/delayed_job start` (or run in the foreground
|
|
242
|
+with `bin/delayed_job run`).
|
|
243
|
+
|
|
244
|
+# Running in production
|
|
245
|
+TODO.
|
|
246
|
+
|
|
247
|
+# Activating your admin user
|
|
248
|
+To activate your admin user, have your server running and go to
|
|
249
|
+`http://localhost:3000/register`. Enter the email address you entered when you
|
|
250
|
+created your Person, and follow the instructions.
|
|
251
|
+
|
|
252
|
+<!--* Deployment instructions-->
|
|
253
|
+
|
|
254
|
+[rbenv]: https://github.com/rbenv/rbenv
|
|
255
|
+[ruby-build]: https://github.com/rbenv/ruby-build
|
|
256
|
+[rbenv-vars]: https://github.com/rbenv/rbenv-vars
|
|
257
|
+[Git]: https://git-scm.com
|
|
258
|
+[Mailgun]: https://mailgun.com
|