67 lines
2.7 KiB
Markdown
67 lines
2.7 KiB
Markdown
# Cloud Foundry: Sample Versatiles App
|
|
|
|
This repository contains the sample code to deploy a [versatiles](https://docs.versatiles.org/) app to STACKIT Cloud Foundry as a docker container.
|
|
It is based on the bundled [front-end](https://docs.versatiles.org/guides/local_server_docker.html#optionb--bundled-frontend-image-versatiles-frontend) image, please refer to versatiles documentation for further information.
|
|
|
|
> NOTE: The project contains a dockerfile, which is merely a wrapper around the public versatiles image. It can be uploaded to a private project in STACKIT Container Registry
|
|
> to demonstrate the usage of private images in Cloud Foundry. You can also use any other registry, public or private.
|
|
|
|
## Preparation
|
|
|
|
Please install and [configure](https://docs.stackit.cloud/stackit/en/how-to-setup-an-object-storage-client-objectstorage-71009862.html) s3cmd in advance.
|
|
|
|
### Object Storage
|
|
|
|
Create a bucket: `s3cmd mb s3://<BUCKET_NAME>`.
|
|
|
|
Make bucket [public](https://docs.stackit.cloud/stackit/en/bucket-policies-75139510.html#BucketPolicies-SampleBucketpolicies>) applying following policy:
|
|
|
|
```json
|
|
{
|
|
"Statement":[
|
|
{
|
|
"Sid": "MakePublicReadable",
|
|
"Effect":"Allow",
|
|
"Principal":"*",
|
|
"Action":"s3:GetObject",
|
|
"Resource":"urn:sgws:s3:::<BUCKET_NAME>/*"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
`s3cmd setpolicy <PATH-TO-POLICY-JSON> s3://<BUCKET_NAME>`
|
|
|
|
Download the `tiles` file: `wget -c "https://download.versatiles.org/osm.versatiles"`.
|
|
|
|
> NOTE: the whole world map is about 65GB.
|
|
|
|
Upload tile file to the bucket:
|
|
|
|
```sh
|
|
s3cmd put <FILE_NAME> s3://<BUCKET_NAME>
|
|
```
|
|
|
|
## Deploy the app with Cloud Foundry
|
|
|
|
Prepare a `vars.yaml` file containing the [variables](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest-attributes.html) used in the manifest.
|
|
|
|
Push the app: `CF_DOCKER_PASSWORD=<YOUR_PASSWORD> cf push --vars-file <PATH-TO-VARS-FILE>`.
|
|
|
|
## Custom Domains
|
|
|
|
Please refer to official STACKIT [documentation](https://docs.stackit.cloud/stackit/en/how-to-register-custom-domains-for-apps-on-stackit-cloud-foundry-67771947.html).
|
|
|
|
## Terraform
|
|
|
|
### Prerequisites
|
|
|
|
As for now, the Cloud Foundry organization and the Stage you deploy into have to be created beforehand.
|
|
In order to create Cloud Foundry resources automatically, you will need a service account and service key. Please refer to the [docs](https://docs.stackit.cloud/stackit/en/how-to-create-cloud-foundry-service-accounts-67772133.html#HowtoCreateCloudFoundryServiceAccounts-StepBySteptotheServiceAccount).
|
|
|
|
### Deployment
|
|
|
|
Change to the `terraform` directory.
|
|
Create a `.tfvars` file and insert the required terraform variables, see [.tfvars.example](./terraform/.tfvars.example):
|
|
|
|
Call `terraform apply --var-file=<PATH-TO-TFVARS-FILE>`.
|