Skip to content

Commit 4dade13

Browse files
authored
Allow admin email and password to be overridden (fixes vmware-archive#369) (vmware-archive#371)
- Adds handling of ADMIN_EMAIL and ADMIN_PASSWORD env vars to deploy scripts - Supersedes vmware-archive#368 - Documents HEROKU_REGION env var - Documents issue identified in vmware-archive#346
1 parent 0719c48 commit 4dade13

File tree

6 files changed

+76
-37
lines changed

6 files changed

+76
-37
lines changed

deployment/README.md

+48-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Deployment
22

3-
1. Download and extract the latest package from the [releases page](https://github.com/pivotal/postfacto/releases)
3+
1. Download and extract the latest `package.zip` from the [releases page](https://github.com/pivotal/postfacto/releases)
44
1. Choose a name for your app, we'll refer to this as `app-name` from now on
5-
1. [Optional] Configure your deployment
5+
1. _[Strongly recommended]_ Choose an admin email and password to override the defaults (`[email protected]` and `password` respectively), we'll refer to these as `admin-email` and `admin-password` from now on
6+
1. _[Optional]_ Configure your deployment:
67
* [Add Google Auth](#allowing-users-to-create-retros)
78
* [Enable analytics](#enabling-analytics)
89
* [Increase the session timeout](#changing-session-timeout)
@@ -21,16 +22,16 @@
2122

2223
In order for users to sign-up and create their own retros using the web UI, Postfacto needs Google OAuth setup.
2324
For deployments that do not want to setup Google OAuth, you will need to create your retros through the admin console of your server via
24-
`<app-name>.cfapps.io/admin` or `<app-name>.<cf-url>/admin`.
25+
`<app-name>.<cf-url>/admin`
2526

2627
1. Go to [Google Cloud Console](https://console.cloud.google.com) and
2728
create a new project
2829
1. Go to APIs & Services > Credentials > Create Credentials > OAuth client ID > Web application
2930
1. Choose a name for your app
30-
1. In `Authorized JavaScript Origins`, set it to the public URL of your `app-name`. For example: if deploying to Heroku, your public URL will be `https://<app-name>.herokuapp.com`.
31+
1. In `Authorized JavaScript Origins`, set it to the public URL of your `app-name`. For example: if deploying to Heroku, your public URL will be `https://<app-name>.herokuapp.com`
3132
1. You can leave redirect blank
3233
1. Take note of your `client-id` that is generated
33-
1. Add `"google_oauth_client_id": {{client-id}}` to the `config.js` for your installation.
34+
1. Add `"google_oauth_client_id": {{client-id}}` to the `config.js` for your installation
3435

3536
### Enabling analytics
3637

@@ -41,7 +42,7 @@ If you'd like to have your instance send analytics data to the Postfacto team so
4142
You can customise this window with the `SESSION_TIME` env variable to the `env` on deploy. To set a session time of 1 hour for example:
4243

4344
```bash
44-
SESSION_TIME=60 ./deploy <app-name>
45+
SESSION_TIME=60 ./deploy.sh <app-name>
4546
```
4647

4748
### Using TLS for database connections
@@ -77,19 +78,27 @@ More information about SSL modes can be found [here](https://www.postgresql.org/
7778
### Removing Redis dependency
7879
If you are on a **later version than 4.3.0** and using Postgres, Redis is no longer required. Instead set the environment variable `USE_POSTGRES_FOR_ACTION_CABLE=true` on deploy.
7980

81+
However, note that for larger retros the live websocket updates may stop working (see [#346](https://github.com/pivotal/postfacto/issues/346)) as the Postgres adapter has an 8kB payload limit.
82+
8083
## Tanzu Application Service
8184

8285
#### Initial deployment
8386

84-
1. Set yourself up with an organization and space in your TAS account to deploy Postfacto to.
85-
1. Add a database (Postgres or Mysql) and a Redis service instance to your space from the Marketplace. Name these services `postfacto-db` and `postfacto-redis`.
86-
1. Run the TAS deployment script from the `tas` directory:
87+
1. Set yourself up with an organization and space in your TAS account to deploy Postfacto to
88+
1. Add a database (Postgres or MySQL) and a Redis service instance to your space from the Marketplace. Name these services `postfacto-db` and `postfacto-redis`
89+
1. Run the TAS deployment script from the `tas` directory, either:
90+
91+
```bash
92+
ADMIN_EMAIL=<admin-email> ADMIN_PASSWORD=<admin-password> ./deploy.sh <app-name>
93+
```
94+
95+
or, to use the default admin credentials (`[email protected]` and `password`):
8796

8897
```bash
8998
./deploy.sh <app-name>
9099
```
91100

92-
Take note of the URL that has shown up in the `routes:` section of the script output, going forward referred to as `<app-url>`.
101+
Take note of the URL that has shown up in the `routes:` section of the script output, going forward referred to as `<app-url>`
93102
1. Log in to the Postfacto admin dashboard (email: `[email protected]` and password: `password`) to check everything has worked at `<app-url>/admin`
94103
1. Create a retro for yourself by clicking on 'Retros' and the 'New Retro'
95104
1. Log in to your retro at `<app-url>/retros/your-retro-slug`
@@ -117,11 +126,18 @@ If you are on a **later version than 4.3.0** and using Postgres, Redis is no lon
117126
1. Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) to your local machine
118127
1. Install [helm](https://helm.sh/docs/intro/install/) to your local machine
119128
1. Make sure `kubectl` is configured to connect to the TKG cluster (ask your administrator for the configuration)
120-
1. Run the deployment script from the `tkg` directory:
129+
1. Run the deployment script from the `tkg` directory, either:
130+
131+
```bash
132+
ADMIN_EMAIL=<admin-email> ADMIN_PASSWORD=<admin-password> ./deploy.sh <app-name>
133+
```
134+
135+
or, to use the default admin credentials (`[email protected]` and `password`):
121136

122137
```bash
123138
./deploy.sh <app-name>
124139
```
140+
125141
1. Keep note of the application url output by the deployment script, going forward referred to as `tkg-url`
126142
1. Log in to the admin dashboard at `<tkg-url>/admin` (email: `[email protected]` and password: `password`)
127143
1. Create a retro for yourself by clicking on 'Retros' and then 'New Retro'
@@ -139,16 +155,22 @@ If you are on a **later version than 4.3.0** and using Postgres, Redis is no lon
139155

140156
#### Initial deployment
141157

142-
1. Set yourself up with an organization and space in your CF to deploy your Postfacto to.
158+
1. Set yourself up with an organization and space in your CF to deploy your Postfacto to
143159
1. Take note of your CF url, going forward referred to as `cf-url`
144-
1. Add a database (Postgres or Mysql) and a Redis service instance to your space from the Marketplace. Name these services `postfacto-db` and `postfacto-redis`.
145-
1. Run the CF deployment script from the `cf` directory:
160+
1. Add a database (Postgres or Mysql) and a Redis service instance to your space from the Marketplace; name these services `postfacto-db` and `postfacto-redis`
161+
1. Run the CF deployment script from the `cf` directory, either:
162+
163+
```bash
164+
ADMIN_EMAIL=<admin-email> ADMIN_PASSWORD=<admin-password> ./deploy.sh <app-name>
165+
```
166+
167+
or, to use the default admin credentials (`[email protected]` and `password`):
146168

147169
```bash
148170
./deploy.sh <app-name>
149171
```
150172

151-
1. Log in to the Postfacto admin dashboard (email: `[email protected]` and password: `password`) to check everything has worked at `<app-name>.<cf-url>/admin`
173+
1. Log in to the Postfacto admin dashboard to check everything has worked at `<app-name>.<cf-url>/admin`
152174
1. Create a retro for yourself by clicking on 'Retros' and then 'New Retro'
153175
1. Log in to your retro at `<app-name>.<cf-url>/retros/your-retro-slug`
154176
1. Share the URL and password with your team and then run a retro!
@@ -173,13 +195,21 @@ If you are on a **later version than 4.3.0** and using Postgres, Redis is no lon
173195
#### Initial deployment
174196

175197
1. Install the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli)
176-
1. Run the Heroku deployment script from the `heroku` directory:
198+
1. Run the Heroku deployment script from the `heroku` directory, either:
199+
200+
```bash
201+
ADMIN_EMAIL=<admin-email> ADMIN_PASSWORD=<admin-password> ./deploy.sh <app-name>
202+
```
203+
204+
or, to use the default admin credentials (`[email protected]` and `password`):
177205

178206
```bash
179207
./deploy.sh <app-name>
180208
```
181209

182-
1. Log in to the Postfacto admin dashboard (email: `[email protected]` and password: `password`) to check everything has worked at `<app-name>.herokuapp.com/admin`
210+
If you want to deploy to the EU [region](https://devcenter.heroku.com/articles/regions), rather than the default US region, prefix the deploy command with `HEROKU_REGION=eu`
211+
212+
1. Log in to the Postfacto admin dashboard to check everything has worked at `<app-name>.herokuapp.com/admin`
183213
1. Create a retro for yourself by clicking on 'Retros' and then 'New Retro'
184214
1. Log in to your retro at `<app-name>.herokuapp.com/retros/your-retro-slug`
185215
1. Share the URL and password with your team and then run a retro!
@@ -208,4 +238,4 @@ If you are on a **later version than 4.3.0** and using Postgres, Redis is no lon
208238
1. Run the smoke test script from the root of the package directory:
209239
```bash
210240
./smoke-test.sh <app-url> <app-admin-url> <test-admin-email> <test-admin-password>
211-
```
241+
```

deployment/deploy-cf.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4242

4343
APP_HOST=$1
4444
SESSION_TIME=${SESSION_TIME:-'""'}
45+
ADMIN_EMAIL="${ADMIN_EMAIL:-email@example.com}"
46+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-password}"
4547

4648
ASSETS_DIR="$SCRIPT_DIR/../assets"
4749
CONFIG_DIR="$SCRIPT_DIR/config"
@@ -51,5 +53,5 @@ cf target \
5153
&& exit 1)
5254

5355
cp "$CONFIG_DIR/config.js" "$ASSETS_DIR/client/config.js"
54-
cf push -f "$CONFIG_DIR"/manifest.yml -p "$ASSETS_DIR" --var api-app-name=$APP_HOST --var session-time=$SESSION_TIME
55-
cf run-task $APP_HOST 'ADMIN_EMAIL=[email protected] ADMIN_PASSWORD=password rake admin:create_user'
56+
cf push -f "$CONFIG_DIR"/manifest.yml -p "$ASSETS_DIR" --var "api-app-name=$APP_HOST" --var "session-time=$SESSION_TIME"
57+
cf run-task "$APP_HOST" "ADMIN_EMAIL=$ADMIN_EMAIL ADMIN_PASSWORD=$ADMIN_PASSWORD rake admin:create_user"

deployment/deploy-heroku.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4343

4444
APP_HOST=$1
4545
SESSION_TIME=${SESSION_TIME:-'""'}
46+
ADMIN_EMAIL="${ADMIN_EMAIL:-email@example.com}"
47+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-password}"
4648
HEROKU_REGION=${HEROKU_REGION:-'us'}
4749

4850
ASSETS_DIR="$SCRIPT_DIR/../assets"
@@ -57,15 +59,15 @@ cp "$CONFIG_DIR/Procfile" "$ASSETS_DIR"
5759
###################
5860

5961
pushd "$ASSETS_DIR"
60-
heroku create ${APP_HOST} --buildpack https://github.com/heroku/heroku-buildpack-ruby.git#v227 --region ${HEROKU_REGION}
61-
heroku addons:create heroku-postgresql:hobby-dev -a ${APP_HOST}
62-
heroku addons:create heroku-redis:hobby-dev -a ${APP_HOST}
63-
heroku config:set WEBSOCKET_PORT=4443 SESSION_TIME=${SESSION_TIME} -a ${APP_HOST}
62+
heroku create "$APP_HOST" --buildpack https://github.com/heroku/heroku-buildpack-ruby.git#v227 --region "$HEROKU_REGION"
63+
heroku addons:create heroku-postgresql:hobby-dev -a "$APP_HOST"
64+
heroku addons:create heroku-redis:hobby-dev -a "$APP_HOST"
65+
heroku config:set WEBSOCKET_PORT=4443 "SESSION_TIME=$SESSION_TIME" -a "$APP_HOST"
6466

6567
rm -rf .git # blow away any existent git directory from a previous run
6668
git init .
6769
git add .
6870
git commit -m "Packaging for initial Heroku deployment"
69-
git push --set-upstream https://git.heroku.com/${APP_HOST}.git main
70-
heroku run rake admin:create_user ADMIN_EMAIL=[email protected] ADMIN_PASSWORD=password -a ${APP_HOST} -x
71+
git push --set-upstream "https://git.heroku.com/$APP_HOST.git" main
72+
heroku run rake admin:create_user "ADMIN_EMAIL=$ADMIN_EMAIL" "ADMIN_PASSWORD=$ADMIN_PASSWORD" -a "$APP_HOST" -x
7173
popd

deployment/deploy-tas.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4141
"$SCRIPT_DIR/mixpanel.sh" "TAS $(basename "${BASH_SOURCE[0]}")" "$@"
4242

4343
APP_HOST=$1
44+
ADMIN_EMAIL="${ADMIN_EMAIL:-email@example.com}"
45+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-password}"
4446
SESSION_TIME=${SESSION_TIME:-'""'}
4547

4648
ASSETS_DIR="$SCRIPT_DIR/../assets"
@@ -51,5 +53,5 @@ cf target \
5153
&& exit 1)
5254

5355
cp "$CONFIG_DIR/config.js" "$ASSETS_DIR/client/config.js"
54-
cf push -f "$CONFIG_DIR"/manifest.yml -p "$ASSETS_DIR" --var api-app-name=$APP_HOST --var session-time=$SESSION_TIME
55-
cf run-task $APP_HOST 'ADMIN_EMAIL=[email protected] ADMIN_PASSWORD=password rake admin:create_user'
56+
cf push -f "$CONFIG_DIR"/manifest.yml -p "$ASSETS_DIR" --var "api-app-name=$APP_HOST" --var "session-time=$SESSION_TIME"
57+
cf run-task "$APP_HOST" "ADMIN_EMAIL=$ADMIN_EMAIL ADMIN_PASSWORD=$ADMIN_PASSWORD rake admin:create_user"

deployment/deploy-tkg.sh

+8-5
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4242
"$SCRIPT_DIR/mixpanel.sh" "TKG $(basename "${BASH_SOURCE[0]}")" "$@"
4343

4444
APP_NAME=$1
45+
ADMIN_EMAIL="${ADMIN_EMAIL:-email@example.com}"
46+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-password}"
4547

46-
helm install $APP_NAME postfacto-*.tgz --set service.type=LoadBalancer
48+
helm install "$APP_NAME" postfacto-*.tgz --set service.type=LoadBalancer
4749

48-
kubectl wait --for=condition=ready --timeout=120s pod -l app.kubernetes.io/instance=${APP_NAME}
49-
POSTFACTO_POD=$(kubectl get pod -l app.kubernetes.io/instance=${APP_NAME} -o jsonpath="{.items[0].metadata.name}")
50-
kubectl exec $POSTFACTO_POD create-admin-user [email protected] password
50+
kubectl wait --for=condition=ready --timeout=120s pod -l "app.kubernetes.io/instance=$APP_NAME"
51+
POSTFACTO_POD=$(kubectl get pod -l "app.kubernetes.io/instance=$APP_NAME" -o jsonpath="{.items[0].metadata.name}")
52+
kubectl exec "$POSTFACTO_POD" create-admin-user "$ADMIN_EMAIL" "$ADMIN_PASSWORD"
5153

52-
export SERVICE_IP=$(kubectl get svc ${APP_NAME} --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
54+
SERVICE_IP=$(kubectl get svc "$APP_NAME" --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
55+
export SERVICE_IP
5356
echo "Access your application at http://$SERVICE_IP"

run.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export RAILS_ENV="development"
3535

3636
# Parse configuration
3737

38-
ADMIN_USER="${ADMIN_USER:-email@example.com}"
39-
ADMIN_PASS="${ADMIN_PASS:-password}"
38+
ADMIN_EMAIL="${ADMIN_EMAIL:-email@example.com}"
39+
ADMIN_PASSWORD="${ADMIN_PASSWORD:-password}"
4040

4141
INFO=""
4242

@@ -58,7 +58,7 @@ fi
5858
pushd "$BASE_DIR/api" >/dev/null
5959
echo "Migrating database..."
6060
bundle exec rake db:create db:migrate
61-
ADMIN_EMAIL="$ADMIN_USER" ADMIN_PASSWORD="$ADMIN_PASS" bundle exec rake admin:create_user
61+
ADMIN_EMAIL="$ADMIN_EMAIL" ADMIN_PASSWORD="$ADMIN_PASSWORD" bundle exec rake admin:create_user
6262
popd >/dev/null
6363

6464
export USE_MOCK_GOOGLE
@@ -80,7 +80,7 @@ if [[ "$USE_MOCK_GOOGLE" == "true" ]]; then
8080
fi
8181

8282
INFO+=$'\n'
83-
INFO+="Created admin user '$ADMIN_USER' with password '$ADMIN_PASS'"$'\n'
83+
INFO+="Created admin user '$ADMIN_EMAIL' with password '$ADMIN_PASSWORD'"$'\n'
8484
INFO+="Log in to http://localhost:4000/admin to administer"$'\n'
8585
INFO+="App will be available at http://localhost:3000/"$'\n'
8686
INFO+="Press 'q' to stop all services"

0 commit comments

Comments
 (0)