Visit pupilfirst.com/changelog to view the full changelog.
- Install and configure dependencies
- Set credentials for local database
- Configure application environment variables
- Setup Overcommit
- Seed local database
- Set up a reverse-proxy using Nginx
- Compile ReasonML, run Webpack Dev Server, and run the Rails Server
We'll use Homebrew to fetch most of the packages on OSX:
- imagemagick -
brew install imagemagick
- redis -
brew install redis
- nginx -
brew install nginx
- postgresql - Install Postgres.app and follow its instructions.
The following command should install all required dependencies on Ubuntu. If you're using another flavour of Linux, adapt the command to work with the package manager available with your distribution.
sudo apt-get install imagemagick redis-server postgresql postgresql-contrib autoconf libtool nginx
Use rbenv to install the version of Ruby specified in the .ruby-version
file.
Once Ruby is installed, fetch all gems using Bundler:
$ bundle install
If installation of of pg
gem crashes, asking for libpq-fe.h
, install the gem with:
find /Applications -name pg_config
gem install pg -- --with-pg-config=/path/to/pg_config
sudo apt-get install libpq-dev
- Install NVM following instructions on the offical repository.
- Install the LTS version of NodeJS:
nvm install --lts
- Install Yarn following offical instructions.. Make sure you do not install NodeJS again along with it (read Yarn instructions).
- Install all node modules with
yarn
command.
If you've installed all node modules using Yarn, then the basic environment should be ready at this point. However, you'll also need to install the Reason CLI toolchain to get all add-on features to work properly in VSCode:
npm install -g reason-cli@latest-macos
(OSX) or @latest-linux
(Linux)
# Run psql command as postgres user.
sudo -u postgres psql postgres
# Set the password for this user.
\password postgres
# Quit.
\q
Copy example.env
to .env
.
$ cp example.env .env
The file contains documentation explaining where you should source its values from. At minimum, edit .env
and set
values for Postgres DB username and password that you used in the previous step.
Overcommit adds automatic checks that prevents us from making silly mistakes when committing changes.
$ overcommit --install
$ overcommit --sign
$ rails db:setup
This will also seed data useful for development. Once you've started the server, you should be able to sign in as
[email protected]
(use the Continue as Developer option in dev env), to test access to all interfaces.
There is an unacknowledged issue with the data-migrate gem that
leaves the list of data migrations unpopulated when the database is seeded. If you intend to run data migrations, or are
setting up the platform for production use, you'll need to manually mark all existing data migrations as up
. To do
this, run the contents of db/data_schema.rb
in the Rails console - it should look something like this:
DataMigrate::Data.define(version: USE_VALUE_FROM_DATA_SCHEMA_FILE)
Use Nginx to set up a reverse proxy on a .localhost
domain to point it to your web application running on port 3000
(the default Rails server port). Use following server configuration as an example:
Place the following configuration at /usr/local/etc/nginx/servers/pupilfirst
(OSX) or at
/etc/nginx/sites-enabled/pupilfirst
(Linux).
server {
listen 80;
server_name school.localhost www.school.localhost sso.school.localhost;
location / {
proxy_pass http://localhost:3000/;
proxy_set_header Host $host;
}
}
You may also need to point the local school domain school.localhost
, and the www
and sso
subdomains, to
127.0.0.1
in the /etc/hosts
file:
127.0.0.1 school.localhost
127.0.0.1 www.school.localhost
127.0.0.1 sso.school.localhost
Compile and watch ReasonML files for changes:
yarn run bsb -make-world -w
On another tab or window, start the Webpack Dev Server:
bin/webpack-dev-server
On another tab or window, run the Rails server:
bundle exec rails server
You'll want all three of these processes running for best performance when developing.
If your Nginx reverse-proxy has been set up correctly, then visit the school using your browser at
http://www.school.localhost
.
You might need to create the test database that you've configured with environment variables.
To execute all tests manually, run:
$ rspec
To generate spec coverage report, run:
COVERAGE=true rspec
This will generate coverage report as HTML within the /coverage
directory.
Background jobs are written using Rails ActiveJob, and deferred using delayed_job in the production environment.
By default, the development and test environment run jobs in-line with a request. If you've manually configured the application to defer them instead, you can execute the jobs with:
$ rake jobs:workoff