Giter Site home page Giter Site logo

stormuk / curriculum.teachcomputing.org Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ncce/curriculum.teachcomputing.org

0.0 1.0 0.0 2.39 MB

Resources Repository

Shell 1.87% JavaScript 1.77% Ruby 89.96% HTML 6.01% Dockerfile 0.06% SCSS 0.30% Procfile 0.04%

curriculum.teachcomputing.org's Introduction

Curriculum

Development

Dependencies:

  • Homebrew
  • Docker (incl. Docker Compose, which already part of Docker for Mac and Docker Toolbox) > v4.0 (with support for docker compose)
  • asdf

Setup

Build the docker image, set up environment variables, and add a nicer local hostname (curriculum.teachcomputing.rpfdev.com):

sh scripts/setup.sh

Optionally set a password for postgres by updating the value for DEV_PASS in your .env file.

Starting and stopping the stack

Start the stack:

docker compose up (-d to detach from shell, see the next section for viewing the logs)

The app is then available at: http://curriculum.teachcomputing.rpfdev.com

Stop the stack:

docker compose down

View logs

View logs (add -f to tail, and/or append a container name such as 'curriculum' to tail only that container):

docker compose logs

For example

docker compose -f logs curriculum

Database

The database is automatically setup the first time the container is run, and a migration is performed on each subsequent run.

Reset the database

yarn run reset-db

Run migrations

To perform migrations manually (without restarting the container) run:

yarn run exec rails db:migrate

#### Seeding the database

To seed manually run:

docker compose run --rm --no-deps curriculum rails db:seed

Install new Dependencies / Updates

The bundle has now been moved to a separate volume and once the initial build has taken place the bundle directory is mapped to a volume and persisted.

To install/update a new gem, first update the Gemfile and run docker-compose run curriculum bundle install or docker-compose run curriculum bundle update, then:

docker compose run --rm --no-deps curriculum bundle install

To reinstall all packages:

docker compose build (--no-cache to force it build from scratch)

Testing

Uses rspec

yarn test

To use guard to watch the tests:

yarn run exec guard

Tooling

ERB Lint

Used for linting ERB / HTML files

Run with bundle exec erblint --lint-all

https://github.com/Shopify/erb-lint

Reek

Used for detecting 'code smell' in your app.

Run with bundle exec reek

Brakeman

Used for static code analysis to check for potential security flaws.

https://brakemanscanner.org/docs/quickstart/

We are ignoring some of the warnings using the method described in the Brakeman docs We are using the default location for the ignore file, etc.

Run brakeman -i config/brakeman.ignore . in the project root and follow the onscreen prompts, outlined in the above doc, to use the tool and check the output for warnings, etc.

Debugging

ruby-debug-ide is enabled and waiting for connections by default on port 1235. There is a launch.json in the repo and if you're using vscode it should be as easy as going to the 'Run' view, selecting 'Debug Attach' and clicking the green Run button. It's important to note that if you attempt to restart or stop the debug process, this will effectively kill the container, and a docker compose up -d will be necessary to continue - however this is rarely necessary in general use since you'll be debugging individual requests.

If you prefer to use byebug you'll first need to attach to the container which can be done with the command: docker attach curriculumteachcomputingorg_curriculum_1 (the container name can be checked with docker compose ps, but mostly it'll be the one here), then add your breakpoint and trigger your request. Again ending the session by quitting byebug or hitting ctrl+c will kill the container, so you'll need to run docker compose up -d again.

Troubleshooting

I can access the site at localhost:3020 but not at curriculum.teachcomputing.rpfdev.com

In some circumstances the nginx instance used by dev-nginx may go down, just run dev-nginx restart-nginx to bring it up again.

Syncing Prod DB to Staging

  • You must have access to the Heroku apps for staging and production.

To copy the production database into the staging database run:

./bin/sync-db/production-to-staging.sh

curriculum.teachcomputing.org's People

Contributors

arayb avatar damienh avatar danhalson avatar dependabot[bot] avatar dumbledad avatar grega avatar magdalenajadach avatar nyashamaphosa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.