Closed adelevie closed 7 years ago
We now automatically set up development, staging, and production spaces in each new org, which should help users avoid binding services across environments. I'm going to close this for now, but please reopen if there's more we should be doing.
Problem
As a dev, I am looking for a standard technique for hosting a web application in production and staging environments. There seem to be multiple ways to approach this problem, but this seems like a process that need not (and should not) be reinvented for each app.
I'm currently struggling through this for a Rails app, but I think the solution here could be framework/language-agnostic.
Current Approach (and down the rabbit hole)
Currently (for Micropurchase), we have an app in the
production
space of our CF org. We have a pretty standard Ruby buildpack, apsql-shared
service, and deploys integrated into Travis-CI.To get a staging site up, I added a
staging
space to our CF org and deployed usingcf push -n micropurchase-staging
. Here's where things get murky:On to the logs!:
(full logs here)
So this is weird and difficult to understand.
The Next Approach
Rather than specify the
-n
flag, lets try using a separate buildpack just for staging (manifest-staging.yml
):Good?! Nope. The logs keep showing this same
PG::InsufficientPrivilege: ERROR: permission denied to create database
error.Nevertheless, the site was up at the desired URL (https://micropurchase-staging.18f.gov). I tried logging in using our app's OAuth login, and got GitHub's 404 page (at this url: https://github.com/login/oauth/authorize?client_id&redirect_uri=https%3A%2F%2Fmicropurchase-staging.18f.gov%2Fauth%2Fgithub%2Fcallback&response_type=code&state=ec086f1a41afddf44cff5ee885fe8b130034e74c2fe1f00e).
Incidentally
cf restage micropurchase
gets me:Along with that same PG error.
Why does
cf push
seem to work fine butcf restage
keeps erroring?Service Name Confusion:
Somehow the same RDS database service is bound to the same three apps (production, staging, and ssh). Maybe this was user (my) error. To correct this, I'll unbind
micropurchase-psql
from themicropurchase
app in thestaging
space:Time to restage:
And that same PG error in the logs ...
While I'm at it, let's check
cf services
to see what's going on:Now everything seems backwards: staging db is bound to plain old
micropurchase
(but in which space?!) andmicrpurchase-psql
is bound tomicropurchase-staging
. Again which, space? (cf target
says I'm instaging
but this is now getting very confusing.Back out of the rabbit hole
Apologies if this meandered too much, but this seems to be the way things are going (at least for me) with Cloud Foundry and debugging it. So many of the steps required are procedural and not declarative. Maybe this exists already, but I'd much prefer to describe the desired setup in the
manfiest.yml
: here's what I need in thestaging
space and here's what I need inproduction
, and then let a space-boundcf push
handle the rest.