The quickest way to get up and running with the ECF2 application is to use a Codespace. Just click 'Code', 'Create codespace on main' and wait for a minute while everything's installed for you. Once it's done you should be able to type bin/dev
in your terminal window and the app will run.
- Ruby 3.3.4 (via rbenv, rvm, or asdf)
- NodeJS (via fnm, nvm or asdf)
- PostgreSQL (via your package manager or Postgres.app)
You'll need to set up some environment variables too. You can do that securely with direnv.
When running the app locally for development purposes we'll often want to drop and recreate the database, so we need to use a superuser.
This assumes your username is joey
. You can check yours by running whoami
-
Ensure PostgreSQL is installed and running
-
Change to the
postgres
user withsudo su -l postgres
-
As the
postgres
user:- Create a database user with the same name as your main main login, i.e.,
createuser --superuser joey
- Edit the
pg_hba.conf
file (found in the data directory in thepostgres
user's home) and add this line to the table at the bottom - this trusts all local connections. It's permissive but fine for development purposes.local all all trust host all all 127.0.0.1/32 trust
- log out (type
exit
)
- Create a database user with the same name as your main main login, i.e.,
-
Restart PostgreSQL.
On Linux this will be something like
sudo systemctl restart postgresql.service
On Mac, if you installed with Homebrew, run
brew services restart postgres
. If you installed Postgres.app, right click on the icon in the control centre and click 'Restart server' -
Now we can test our user account is working properly. By default, running the
postgres
command with no arguments will connect with your username to a database named after your username (i.e. it will connect with the userjoey
to a database calledjoey
).We should be able to create a database with
createdb joey
Then, running
psql
should connect and give us a prompt like this:$ psql psql (16.3) Type "help" for help. joey=#
If that worked, we're done. You can quit the database prompt with
\q
or by pressingctrl+d
Once you have Ruby and NodeJS installed we're ready to install the application's dependencies.
We can do this in one step with bin/setup
:
$ bin/setup
# == Installing dependencies ==
# The Gemfile's dependencies are satisfied
#
# up to date, audited 22 packages in 932ms
#
# found 0 vulnerabilities
#
# == Preparing database ==
# Created database 'ecf2_development'
# Created database 'ecf2_test'
#
# == Removing old logs and tempfiles ==
#
# == Restarting application server ==
Or you can do each step manually with:
$ bundle install
$ npm install
$ bundle exec rails db:setup
Once all the dependencies are installed we can run the application.
$ bin/dev
Navigate to https://localhost:3000 in your browser and if you can see a website, everything's working! 🥳
Go and put the kettle on.