This is an experimental fork of the new EYFS CMS adapted for use for the GHRE service
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)
Ruby version 2.7.2
Node version 14.x.x
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
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:
brew services
- to check for any running instances,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
cancel the running docker process and then run docker-compose down
(for a full reset on your environment)
docker exec -it eyfs-reform-spike_app_1 sh
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.
> FATAL: password authentication failed for user "boilerplate_user"
You can manually set a password for the user boilerplate_user
by following these steps:
docker-compose exec database psql -d postgres -U boilerplate_user
- in the postgres cli run
\password
- set the
DATABASE_PASSWORD
from.env
See this guide for advice about how to layout html
When a branch is merged into main
- a docker image is built and pushed to DockerHub
Check out documentation folder
- Ruby 2.7.1
- PostgreSQL
- NodeJS 12.13.x
- Yarn 1.12.x
- Run
bundle install
to install the gem dependencies - Run
yarn
to install node dependencies - Run
bin/rails db:setup
to set up the database development and test schemas, and seed with test data - Run
bundle exec rails server
to launch the app on http://localhost:3000 - Run
./bin/webpack-dev-server
in a separate shell for faster compilation of assets
- Rails 6.0 with Webpacker
- GOV.UK Frontend
- RSpec
- Dotenv (managing environment variables)
- Travis with Heroku deployment
bundle exec rake
bundle exec rspec
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
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
- 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
- Run
cf login -a api.london.cloud.service.gov.uk -u USERNAME
,USERNAME
is your personal GOV.UK PaaS account email address - Run
bundle package --all
to vendor ruby dependencies - Run
yarn
to vendor node dependencies - Run
bundle exec rails webpacker:compile
to compile assets - 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).
- They can be run manually in IDE
- Command line
- Intention for these integration / e2e tests to run in AWS CI pipeline
Right click on 'Feature' and run Or Run - Edit Configurations (depending on IDE)
cucumber --color -r e2etestname.feature
- 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