This is the codebase for the Ruby/Rails app that will handle the submission of Lettings and Sales of Social Housing in England data.
This is the codebase for the Ruby on Rails app that will handle the submission of Lettings and Sales of Social Housing in England data.
## Required Setup
## Required Setup
Pre-requisites
Pre-requisites:
- Ruby
- Ruby
- Rails
- Rails
- Postgres
- Postgres
### Quick start
### Setup Quickstart
1. Copy the `.env.example` to `.env` and replace the database credentials with your local postgres user credentials.
Copy the `.env.example` to `.env` and replace the database credentials with your local postgres user credentials.
2. Install the dependencies:\
`bundle install`
Install the dependencies
3. Create the database:\
`bundle install`
`rake db:create`
Create the database
4. Run the database migrations:\
`rake db:create`
`rake db:migrate`
Run the database migrations
5. Install the frontend depenencies:\
`rake db:migrate`
`yarn install`
Start the rails server
6. Start the Rails server:\
```
`bundle exec rails s`
rails s
```
This starts the rails server on localhost:3000
or using Docker
The Rails server will start on <http://localhost:3000>.
```
### Using Docker
```sh
docker-compose build
docker-compose build
docker-compose run --rm app rails db:create
docker-compose run --rm app rails db:create
docker-compose up
docker-compose up
```
```
This exposes the rails server on localhost:8080.
The Rails server will start on <http://localhost:8080>.
Note docker-compose runs the production docker image (RAILS_ENV=production) as the Dockerfile doesn't include development gems to keep the image size down.
Note `docker-compose` runs the production docker image (`RAILS_ENV=production`) as the Dockerfile doesn’t include development gems to keep the image size down.
## Infrastructure
### Infrastructure
This application is running on [GOV.UK PaaS](https://www.cloud.service.gov.uk/). To deploy you need to:
This application is running on [Gov PaaS](https://www.cloud.service.gov.uk/). To deploy you need to:
1. Contact your organisation manager to get an account in `dluhc-core` organization and in the relevant spaces (sandbox/production).
- Contact your organisation manager to get an account in `dluhc-core` organization and in the relevant spaces (sandbox/production).
2. [Install the Cloud Foundry CLI](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html)
- Install the cloudfoundry cli https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
- Login <br/>
3. Login:\
`cf login -a api.london.cloud.service.gov.uk -u <your_username>`
`cf login -a api.london.cloud.service.gov.uk -u <your_username>`
- Set your deployment target (sandbox/production) <br/>
4. Set your deployment target (sandbox/production):\
`cf target -o dluhc-core -s <deploy_environment>`
`cf target -o dluhc-core -s <deploy_environment>`
- Deploy <br/>
5. Deploy:\
`cf push dluhc-core --strategy rolling`. This will use the [manifest file](manifest.yml)
`cf push dluhc-core --strategy rolling`. This will use the [manifest file](manifest.yml)