support for deployments to cloudfoundry (#116)
* support for deploying to cloudfoundry * tweaking readme
This commit is contained in:
parent
566f2a354c
commit
890ff87a9c
|
@ -0,0 +1,14 @@
|
|||
# golang-url-shortener on cloudfoundry
|
||||
|
||||
## configuration
|
||||
|
||||
1. Either compile or download the linux amd64 binary and copy it into this directory (e.g. `cp ../../releases/golang-url-shortener_linux_amd64/golang-url-shortener .` if you compiled it yourself via make)
|
||||
1. `cp manifest-example.yml manifest.yml` and edit to meet your needs
|
||||
1. (optional) create any services that may be required for securing env variables or things like redis, for example:
|
||||
* creating a cups service to hold oauth keys: `cf create-user-provided-service gourl-oauth -p '{"githubClientID":"<some id>","githubClientSecret":"<some key>"}'`
|
||||
* creating a redis service for later binding: `cf create-service thd-redis default gourl-redis-service`
|
||||
1. (optional) modify run.sh to set `REDIS_SERVICE_NAME` to match the name of the redis service for your cloudfoundry implementation
|
||||
|
||||
## deployment
|
||||
|
||||
`cf push` or `cf push <custom app name>`
|
|
@ -0,0 +1,19 @@
|
|||
applications:
|
||||
- name: gourl
|
||||
buildpack: binary_buildpack
|
||||
memory: 64m
|
||||
command: './run.sh'
|
||||
instances: 1 # should not be more than 1 due to session handling
|
||||
health-check-type: http
|
||||
health-check-http-endpoint: /ok
|
||||
# if you use any marketplace or cups services, define the binding here
|
||||
# services:
|
||||
# - gourl-redis-service
|
||||
# - gourl-oauth
|
||||
# define any configuration settings via environment variables here (see https://github.com/mxschmitt/golang-url-shortener/wiki/Configuration)
|
||||
env:
|
||||
GUS_BASE_URL: "https://gourl.mydomain.com"
|
||||
GUS_BACKEND: redis
|
||||
GUS_SHORTED_ID_LENGTH: 5
|
||||
GUS_ENABLE_DEBUG_MODE: false
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
REDIS_SERVICE_NAME="thd-redis"
|
||||
|
||||
CUPS=$(echo $VCAP_SERVICES | grep "user-provided")
|
||||
REDIS=$(echo $VCAP_SERVICES | grep "$REDIS_SERVICE_NAME")
|
||||
|
||||
if [ "$CUPS" != "" ]; then
|
||||
export GUS_GITHUB_CLIENT_ID="$(echo $VCAP_SERVICES | jq -r '.["'user-provided'"][0].credentials.githubClientID')"
|
||||
export GUS_GITHUB_CLIENT_SECRET="$(echo $VCAP_SERVICES | jq -r '.["'user-provided'"][0].credentials.githubClientSecret')"
|
||||
fi
|
||||
|
||||
if [ "$REDIS" != "" ]; then
|
||||
export GUS_REDIS_HOST="$(echo $VCAP_SERVICES | jq -r '.["'$REDIS_SERVICE_NAME'"][0].credentials.host'):$(echo $VCAP_SERVICES | jq -r '.["'$REDIS_SERVICE_NAME'"][0].credentials.port')"
|
||||
export GUS_REDIS_PASSWORD="$(echo $VCAP_SERVICES | jq -r '.["'$REDIS_SERVICE_NAME'"][0].credentials.password')"
|
||||
fi
|
||||
|
||||
echo "#### Starting golang-url-shortener..."
|
||||
|
||||
./golang-url-shortener
|
Loading…
Reference in New Issue