Browse Source

Environments (#226)

* Rename sandbox to staging

* Named manifest

* Sort files together

* Use a single manifest file

* Bump

* Host doesn't do anything yet

* Add S3 bucket creation to readme
pull/243/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
da4abbaafe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      .github/workflows/pipeline.yml
  2. 2
      Gemfile.lock
  3. 10
      README.md
  4. 2
      config/database.yml
  5. 0
      config/environments/staging.rb
  6. 2
      config/webpack/staging.js
  7. 2
      config/webpacker.yml
  8. 2
      docs/api/DLUHC-CORE-Data.v1.json
  9. 21
      infrastructure_setup.md
  10. 31
      manifest.yml

8
.github/workflows/pipeline.yml

@ -7,7 +7,7 @@ on:
pull_request: pull_request:
workflow_dispatch: workflow_dispatch:
concurrency: 'sandbox' concurrency: 'staging'
defaults: defaults:
run: run:
@ -95,7 +95,7 @@ jobs:
name: Deploy name: Deploy
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: 'sandbox' environment: 'staging'
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
needs: [lint, test] needs: [lint, test]
@ -118,7 +118,7 @@ jobs:
CF_ORG: ${{ secrets.CF_ORG }} CF_ORG: ${{ secrets.CF_ORG }}
API_USER: ${{ secrets.API_USER }} API_USER: ${{ secrets.API_USER }}
API_KEY: ${{ secrets.API_KEY }} API_KEY: ${{ secrets.API_KEY }}
APP_NAME: dluhc-core APP_NAME: dluhc-core-staging
GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }} GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }}
APP_HOST: ${{ secrets.APP_HOST }} APP_HOST: ${{ secrets.APP_HOST }}
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
@ -131,4 +131,4 @@ jobs:
cf7 set-env $APP_NAME GOVUK_NOTIFY_API_KEY $GOVUK_NOTIFY_API_KEY cf7 set-env $APP_NAME GOVUK_NOTIFY_API_KEY $GOVUK_NOTIFY_API_KEY
cf7 set-env $APP_NAME APP_HOST $APP_HOST cf7 set-env $APP_NAME APP_HOST $APP_HOST
cf7 set-env $APP_NAME RAILS_MASTER_KEY $RAILS_MASTER_KEY cf7 set-env $APP_NAME RAILS_MASTER_KEY $RAILS_MASTER_KEY
cf7 push --strategy rolling cf7 push $APP_NAME --strategy rolling

2
Gemfile.lock

@ -1,6 +1,6 @@
GIT GIT
remote: https://github.com/activeadmin/arbre.git remote: https://github.com/activeadmin/arbre.git
revision: 305c221a2131be8dd0d96955f9b0a328dfa4beba revision: dcea09da31322f2bc9bdfc32eb14ec0aaf34ae92
specs: specs:
arbre (1.4.0) arbre (1.4.0)
activesupport (>= 3.0.0, < 7.1) activesupport (>= 3.0.0, < 7.1)

10
README.md

@ -53,26 +53,26 @@ Note `docker-compose` runs the production docker image (`RAILS_ENV=production`)
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.UK 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). 1. Contact your organisation manager to get an account in `dluhc-core` organization and in the relevant spaces (staging/production).
2. [Install the Cloud Foundry CLI](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html) 2. [Install the Cloud Foundry CLI](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html)
3. Login:\ 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>`
4. Set your deployment target (sandbox/production):\ 4. Set your deployment target (staging/production):\
`cf target -o dluhc-core -s <deploy_environment>` `cf target -o dluhc-core -s <deploy_environment>`
5. Deploy:\ 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](staging_manifest.yml)
Once the app is deployed: Once the app is deployed:
1. Get a Rails console:\ 1. Get a Rails console:\
`cf ssh dluhc-core -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails console' ''"` `cf ssh dluhc-core-staging -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails console' ''"`
2. Check logs:\ 2. Check logs:\
`cf logs dluhc-core --recent` `cf logs dluhc-core-staging --recent`
#### Troubleshooting deployments #### Troubleshooting deployments

2
config/database.yml

@ -31,7 +31,7 @@ development:
database: data_collector_development database: data_collector_development
host: localhost host: localhost
sandbox: staging:
<<: *default <<: *default
# The specified database role being used to connect to postgres. # The specified database role being used to connect to postgres.

0
config/environments/sandbox.rb → config/environments/staging.rb

2
config/webpack/sandbox.js → config/webpack/staging.js

@ -1,4 +1,4 @@
process.env.NODE_ENV = process.env.NODE_ENV || 'sandbox' process.env.NODE_ENV = process.env.NODE_ENV || 'staging'
const environment = require('./environment') const environment = require('./environment')

2
config/webpacker.yml

@ -95,7 +95,7 @@ test:
public_output_path: packs-test public_output_path: packs-test
sandbox: staging:
<<: *default <<: *default
production: production:

2
docs/api/DLUHC-CORE-Data.v1.json

@ -8,7 +8,7 @@
"servers": [ "servers": [
{ {
"url": "https://dluhc-core.london.cloudapps.digital", "url": "https://dluhc-core.london.cloudapps.digital",
"description": "Sandbox" "description": "Staging"
} }
], ],
"paths": { "paths": {

21
infrastructure_setup.md

@ -0,0 +1,21 @@
# Staging
1. Login:\
`cf login -a api.london.cloud.service.gov.uk -u <your_username>`
2. Set your deployment target (staging):\
`cf target -o dluhc-core -s staging`
3. Create required Postgres and S3 bucket backing services (this will take ~15 mins to finish creating):\
`cf create-service postgres tiny-unencrypted-13 dluhc-core-staging-postgres`
`cf create-service aws-s3-bucket default dluhc-core-staging-import-bucket`
`cf create-service aws-s3-bucket default dluhc-core-staging-export-bucket`
`cf bind-service dluhc-core-staging dluhc-core-staging-import-bucket -c '{"permissions": "read-only"}'`
`cf bind-service dluhc-core-staging dluhc-core-staging-export-bucket -c '{"permissions": "read-write"}'`
4. Deploy manifest:\
`cf push dluhc-core-staging --strategy rolling`

31
manifest.yml

@ -1,14 +1,25 @@
--- ---
defaults: &defaults
buildpacks:
- https://github.com/cloudfoundry/ruby-buildpack.git
processes:
- type: web
command: rake db:migrate && bin/rails server
instances: 2
memory: 512M
applications: applications:
- name: dluhc-core - name: dluhc-core-staging
buildpacks: <<: *defaults
- https://github.com/cloudfoundry/ruby-buildpack.git
env: env:
RAILS_ENV: sandbox RAILS_ENV: staging
processes:
- type: web
command: rake db:migrate && bin/rails server
instances: 2
memory: 512M
services: services:
- dluhc-core-sandbox-postgres - dluhc-core-staging-postgres
- name: dluhc-core-production
<<: *defaults
env:
RAILS_ENV: production
host: submit-social-housing-lettings-sales-data
services:
- dluhc-core-production-postgres

Loading…
Cancel
Save