Skip to main content

Teacher Training Entitlement - setup

< Back to Navigation

  1. Local development
  2. Codespaces
  3. Docker Compose

Local development

  1. Install the prerequisites (see .tool-versions for versions):
    • Ruby
    • PostgreSQL 14
    • NodeJS
    • Yarn
    • Graphviz
  2. Run bundle install to install the gem dependencies
  3. Run yarn to install node dependencies
  4. Run bin/rails db:setup to set up the database development and test schemas, and seed with test data
  5. Copy .env.example to .env and fill in the values (ask a team member for TRA_OIDC_* values)
  6. Run ./bin/dev to launch the app on http://localhost:3000 and auto-compile assets

Codespaces

  1. Click the green 'Code' button on the repository home page and click 'Create a Codespace'
  2. Run bundle exec rails server in the terminal window at the bottom of VS Code

If you're unfamiliar with what Codespaces are or how they work read the official guiude. If you don't have access to them you can request it in #digital-tools-support on DfE Slack.

Docker Compose

You only need Docker on your machine. Start the stack (database and application) for development:

docker compose up -d

Open http://localhost:3000 to browse the app. Edit code as normal (the project directory is mounted as a volume.)

Prefix other commands with docker compose run web, e.g.:

  • docker compose run web bundle exec rails c
  • docker compose run web bundle exec rails db:migrate
  • docker compose run web bundle exec rake
  • docker compose run web bundle add foobar

n.b. to run parallel tests, you need to explicitly set RAILS_ENV e.g.: docker compose run -e RAILS_ENV=test web bundle exec rake parallel:spec

If you need to rebuild the image (e.g. Gemfile.lock changed), add --build: docker compose up -d --build

ops service

The ops service (docker compose run ops) starts a bash shell with make, az and kubectl ready to use.

You can also use this service to run konduit:

  1. After installing with make install-konduit as normal, edit konduit.sh:

    1. In open_tunnels() change kubectl port-forward [...] to kubectl port-forward --address 0.0.0.0 [...]
    2. In set_db_psql(), edit DB_URL= replacing 127.0.0.1:${LOCAL_PORT} with konduit:${LOCAL_PORT}
  2. To create the tunnel, docker compose run --rm --name konduit ops make <target environment> konduit