Git Product home page Git Product logo

get-help-with-remote-education-cms's Introduction

Deploy

This is an experimental fork of the new EYFS CMS adapted for use for the GHRE service

Early Years Reform Framework

This is a minimalistic content management system, written in Ruby on Rails for use by content editors in the Early Years Reform Framework project.

It allows editors to create a set of nested pages, and to edit the headings, overview and content as Markdown.

These are some examples of the cut down CMS and two resulting pages all in UK.GOV style;

![The CMS view](docs/cms-view.png?raw=true "The CMS view"seed) Example page

Prerequisites

Ruby version 2.7.2

Node version 14.x.x

Getting started on Docker

On Mac OS, Docker Desktop / Docker for Mac will need to be installed first and running

Setup a .env file to hold environment variables (do not commit this file)

cp .env.local.example .env

To run the application locally with docker:

NOTE: Ensure no instances of PostgreSQL are running in the background as this can cause conflicts when attempting to run the docker instance of PostgreSQL If PostgreSQL was installed using homebrew, in the terminal use:

  1. brew services - to check for any running instances,
  2. brew services stop postgres

To run the application locally with docker:

docker-compose build && docker-compose up

If docker has been setup correctly, running sudo docker ps, you should see 2 containers running like this:

CONTAINER ID   IMAGE                   COMMAND                  CREATED       STATUS         PORTS                    NAMES
005b86d0b4dc   eyfs-reform-spike_app   "./entrypoints/docke…"   5 hours ago   Up 5 minutes   0.0.0.0:3000->3000/tcp   eyfs-reform-spike_app_1
460c5fe17d37   postgres:13.1           "docker-entrypoint.s…"   5 hours ago   Up 5 minutes   0.0.0.0:5432->5432/tcp   eyfs-reform-spike_database_1

To setup the database running in a docker container (runs terminal command inside of your docker container):

docker-compose exec app bundle exec rake db:setup docker-compose exec app bundle exec rake db:migrate docker-compose exec app bundle exec rake db:seed

To restart the server

cancel the running docker process and then run docker-compose down (for a full reset on your environment)

To connect to the docker container and run commands

docker exec -it eyfs-reform-spike_app_1 sh

Authentication

Devise is used for the CMS routes. Basic Auth can be turned on for the whole site by setting and environment variable called AUTH_ON_EVERYTHING.

The ContentController will then use the devise accounts to check the basic auth, but it does not log users in.

If there are issues with postgres password authentication failure:

> FATAL: password authentication failed for user "boilerplate_user"

You can manually set a password for the user boilerplate_user by following these steps:

  1. docker-compose exec database psql -d postgres -U boilerplate_user
  2. in the postgres cli run \password
  3. set the DATABASE_PASSWORD from .env

Styling pages

See this guide for advice about how to layout html

CI/CD

When a branch is merged into main

  • a docker image is built and pushed to DockerHub

Documentation

Check out documentation folder

The following is from the template repository GOV.UK Rails Boilerplate

Prerequisites

  • Ruby 2.7.1
  • PostgreSQL
  • NodeJS 12.13.x
  • Yarn 1.12.x

Setting up the app in development

  1. Run bundle install to install the gem dependencies
  2. Run yarn to install node dependencies
  3. Run bin/rails db:setup to set up the database development and test schemas, and seed with test data
  4. Run bundle exec rails server to launch the app on http://localhost:3000
  5. Run ./bin/webpack-dev-server in a separate shell for faster compilation of assets

Whats included in this boilerplate?

  • Rails 6.0 with Webpacker
  • GOV.UK Frontend
  • RSpec
  • Dotenv (managing environment variables)
  • Travis with Heroku deployment

Running specs, linter(without auto correct) and annotate models and serializers

bundle exec rake

Running specs

bundle exec rspec

Linting

It's best to lint just your app directories and not those belonging to the framework, e.g.

bundle exec rubocop app config db lib spec Gemfile --format clang -a

or

bundle exec scss-lint app/webpacker/styles

Vscode - Rubocop has a vscode extension, linting may need to be turned on

Using Amazon S3 Bucket for asset storage (e.g. in production)

Ensure you have added 4 parameters to the .env file, these are (ACCESS_KEY_ID, SECRET_ACCESS_KEY, REGION, BUCKET) e.g:

ACCESS_KEY_ID=7867867687
SECRET_ACCESS_KEY=876876876
REGION=eu-west-2
BUCKET=eyfsreformspike

These 4 parameters will be picked up by the Amazon config setting in config/storage.yml You can obtain the access key ID and secret access key as a download from the AWS account Region should be eu-west-2 (London) You must create the parent bucket in AWS first and then add this bucket name to the final parameter(line) Do not encapsulate the strings

Ensure that the appropriate environment file (e.g. environments/production.rb) has been set to use Amazon as storage service:

config.active_storage.service = :amazon

Note: Docker can't be used to connect to AWS

Deploying on GOV.UK PaaS

Prerequisites

  • Your department, agency or team has a GOV.UK PaaS account
  • You have a personal account granted by your organisation manager
  • You have downloaded and installed the Cloud Foundry CLI for your platform

Deploy

  1. Run cf login -a api.london.cloud.service.gov.uk -u USERNAME, USERNAME is your personal GOV.UK PaaS account email address
  2. Run bundle package --all to vendor ruby dependencies
  3. Run yarn to vendor node dependencies
  4. Run bundle exec rails webpacker:compile to compile assets
  5. Run cf push to push the app to Cloud Foundry Application Runtime

Check the file manifest.yml for customisation of name (you may need to change it as there could be a conflict on that name), buildpacks and eventual services (PostgreSQL needs to be set up).

Cucumber Tests

To run

  • They can be run manually in IDE
  • Command line
  • Intention for these integration / e2e tests to run in AWS CI pipeline

IDE

Right click on 'Feature' and run Or Run - Edit Configurations (depending on IDE)

Command Line

cucumber --color -r e2etestname.feature

AWS CI pipeline (Drone.yml configuration)

- Ruby E2E Tests
-   e2e-test:
-     group: ?
-     image: ruby:2.7.2
-     commands:
-       - cd e2etests
-       - gem install bundler
-       - bundle install
-       - cucumber --color -r features -p [insert env]
-     when:
-       trigger:
-         branch:
-           - tbc/*
-         event:
-           - push

get-help-with-remote-education-cms's People

Contributors

guy-roberts avatar tonyto avatar dependabot-preview[bot] avatar ebrett avatar marcrice09 avatar tunde-anddigital avatar marcgr1 avatar dmallett1 avatar jeddf avatar dependabot[bot] avatar guy-roberts-dfe avatar

Watchers

James Cloos avatar Robin Parker avatar SFADevOps avatar  avatar

Forkers

uk-gov-mirror

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.