Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

deploy openresty-cos container to cloudfoundry #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
env.local
test.py
deploy2kube.yaml
manifest.yaml
16 changes: 16 additions & 0 deletions 04_manifest_cf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

source ./env.local

###################################################
# prepare your container as cloud foundry app #
###################################################
cp manifest.template manifest.yaml
# replacements with sed using , syntax because we have slahes in url
sed -i '' "s,@REGISTRY@,${namespace},g" manifest.yaml
sed -i '' "s,@S3_ACCESS_KEY@,${S3_ACCESS_KEY},g" manifest.yaml
sed -i '' "s,@S3_SECRET_KEY@,${S3_SECRET_KEY},g" manifest.yaml
sed -i '' "s,@S3_BUCKET@,${S3_BUCKET},g" manifest.yaml
sed -i '' "s,@COS_ENDPOINT@,${COS_ENDPOINT},g" manifest.yaml
sed -i '' "s,@COS_URI@,${COS_URI},g" manifest.yaml
sed -i '' "s,@NGINX_LOCATION@,${NGINX_LOCATION},g" manifest.yaml
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,29 @@ http://s3tools.org/s3cmd
TODO:
1. Build Helmchart
2. Document example

---

## Alternative Openresty-COS deployment with Cloudfoundry/Docker

CloudFoundry/Docker example to access and cache private elements in IBM Cloud Object Storage with AWS Signature Version 4 support

Prerequisites:

* IBM Cloud Account

* Private IBM Cloud Container Registry namespace for docker container <https://console.bluemix.net/docs/services/Registry/index.html#registry_namespace_add>

* IBM Cloud Object Storage Instance with bucket and HMAC credentials <https://console.bluemix.net/docs/services/cloud-object-storage/hmac/credentials.html#using-hmac-credentials>

* s3cmd installed, separate configuration not needed, everything needed will be passed by 01_s3sync.sh script <http://s3tools.org/s3cmd>

Setup:

1. copy env.local.sample to env.local
2. adjust settings in env.local to match your COS and Container Registry namespace
3. execute `./01_s3sync.sh` this will copy the wwwroot example page to your bucket
4. execute `./02_buildimages.sh` this will build the Docker image and push to IBM Cloud Container Registry Service
5. execute `./04_manifest_cf.sh` this will create a Cloud Foundry manifest.yaml to deploy your private openresty-cos docker-image
6. execute `CF_DOCKER_PASSWORD=$(ibmcloud cr token-add -q) ibmcloud cf push APP_NAME` (**APP_NAME** must be unique)
7. open https://**APP_NAME**.mybluemix.net/index.html in your browser _**NOTE**: keep in mind that each IBM Cloud region has it's own domain. To display your app's route execute: `ibmcloud cf app APP_NAME | grep routes`_
14 changes: 14 additions & 0 deletions manifest.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
applications:
- instances: 1
memory: 128M
stack: cflinuxfs2
docker:
image: @REGISTRY@/openresty-cos:latest
username: token
env:
S3_ACCESS_KEY: @S3_ACCESS_KEY@
S3_SECRET_KEY: @S3_SECRET_KEY@
S3_BUCKET: @S3_BUCKET@
COS_URI: @COS_URI@
COS_ENDPOINT: @COS_ENDPOINT@
NGINX_LOCATION: @NGINX_LOCATION@