Skip to content

Commit a12a99d

Browse files
committed
paas: add deployment on Render and DigitalOcean
1 parent ef9c8b5 commit a12a99d

22 files changed

+926
-12
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@ This repo is using [Opentofu](https://opentofu.org/) and other tools to create c
33

44
## Platform Support Status
55

6-
| | VM | Docker | K8s |
7-
|-----------------------|-------------|-------------------|--------------|
8-
| Microsoft Azure | VM ✅ | ACI ✅ | AKS 🔲 |
9-
| Amazon Web Services | EC2 ✅ | ECS(Fargate) ✅ | EKS 🔲 |
10-
| Google Cloud Platform | GCE ✅ | Cloud Run ✅ | GKE 🔲 |
11-
| Render || DOCKER ✅🚧(See 1) ||
12-
| Heroku || HCR 🚧 ||
13-
| DigitalOcean | Droplets 🚧 | CR 🚧 | DOKS 🔲 |
14-
| Native K8s ||| K8S ✅(See 2) |
6+
| | VM | Docker | K8s |
7+
|-----------------------|------------|-----------------|--------------|
8+
| Microsoft Azure | VM ✅ | ACI ✅ | AKS 🔲 |
9+
| Amazon Web Services | EC2 ✅ | ECS(Fargate) ✅ | EKS 🔲 |
10+
| Google Cloud Platform | GCE ✅ | Cloud Run ✅ | GKE 🔲 |
11+
| Render || DOCKER ✅(See 1) ||
12+
| DigitalOcean | Droplets ✅ | AP ⚠️(See 3) | DOKS 🔲 |
13+
| Native K8s ||| K8S ✅(See 2) |
1514

1615
The following icons are used to represent the status of support for each platform:
1716
- ✅: completed
17+
- ⚠️: partially completed
1818
- 🚧: in progress
1919
- ❌: not applicable
2020
- 🔲: not started
2121

22-
1. Completed by Aaron, you can find Render deployment file here: [onebusaway-docker](https://github.com/OneBusAway/onebusaway-docker), will be integrated into this repo.
22+
1. Completed by Aaron, you can find Render deployment file here: [onebusaway-docker](https://github.com/OneBusAway/onebusaway-docker), has been integrated into this repo.
2323
2. Completed by Neo2308, you can find `oba.yaml` here: [onebusaway-docker](https://github.com/OneBusAway/onebusaway-docker), will be rewrite in [Kustomize](https://github.com/kubernetes-sigs/kustomize).
24+
3. DigitalOcean app engine's gVisor is conflicting with supervisor, they already know this issue and will fix it in the future.

modules/aws-ec2/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "username" {
1717
}
1818

1919
variable "caddy" {
20-
description = "Wheather to use Caddy or not, leave empty to disable"
20+
description = "Whether to use Caddy or not, leave empty to disable"
2121
type = string
2222
default = "1"
2323
}

modules/azure-vm/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ variable "size" {
1111
}
1212

1313
variable "caddy" {
14-
description = "Wheather to use Caddy or not, leave empty to disable"
14+
description = "Whether to use Caddy or not, leave empty to disable"
1515
type = string
1616
default = "1"
1717
}

modules/digitalocean-ap/.terraform.lock.hcl

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/digitalocean-ap/main.tf

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
terraform {
2+
required_providers {
3+
digitalocean = {
4+
source = "digitalocean/digitalocean"
5+
version = "~> 2.0"
6+
}
7+
}
8+
}
9+
10+
provider "digitalocean" {
11+
token = var.digitalocean_token
12+
}
13+
14+
resource "digitalocean_app" "main" {
15+
spec {
16+
name = "onebusaway-api-server"
17+
region = var.region
18+
19+
service {
20+
name = "onebusaway-api-webapp"
21+
image {
22+
registry_type = "DOCKER_HUB"
23+
registry = "opentransitsoftwarefoundation"
24+
repository = "onebusaway-api-webapp"
25+
tag = "2.5.12-cs-v1.0.0"
26+
}
27+
instance_size_slug = var.instance_size_slug
28+
instance_count = var.num_instances
29+
30+
env {
31+
key = "TZ"
32+
value = var.env_var_tz
33+
scope = "RUN_AND_BUILD_TIME"
34+
}
35+
env {
36+
key = "GTFS_URL"
37+
value = var.env_var_gtfs_url
38+
scope = "RUN_AND_BUILD_TIME"
39+
}
40+
env {
41+
key = "VEHICLE_POSITIONS_URL"
42+
value = var.env_var_vehicle_positions_url
43+
scope = "RUN_AND_BUILD_TIME"
44+
}
45+
env {
46+
key = "TRIP_UPDATES_URL"
47+
value = var.env_var_trip_updates_url
48+
scope = "RUN_AND_BUILD_TIME"
49+
}
50+
env {
51+
key = "ALERTS_URL"
52+
value = var.env_var_alerts_url
53+
scope = "RUN_AND_BUILD_TIME"
54+
}
55+
env {
56+
key = "FEED_API_KEY"
57+
value = var.env_var_feed_api_key
58+
scope = "RUN_AND_BUILD_TIME"
59+
}
60+
env {
61+
key = "FEED_API_VALUE"
62+
value = var.env_var_feed_api_value
63+
scope = "RUN_AND_BUILD_TIME"
64+
}
65+
env {
66+
key = "REFRESH_INTERVAL"
67+
value = var.env_var_refresh_interval
68+
scope = "RUN_AND_BUILD_TIME"
69+
}
70+
env {
71+
key = "AGENCY_ID"
72+
value = var.env_var_agency_id
73+
scope = "RUN_AND_BUILD_TIME"
74+
}
75+
env {
76+
key = "JDBC_USER"
77+
value = var.env_var_jdbc_user
78+
scope = "RUN_AND_BUILD_TIME"
79+
}
80+
env {
81+
key = "JDBC_PASSWORD"
82+
value = var.env_var_jdbc_password
83+
scope = "RUN_AND_BUILD_TIME"
84+
}
85+
env {
86+
key = "JDBC_URL"
87+
value = var.env_var_jdbc_url
88+
scope = "RUN_AND_BUILD_TIME"
89+
}
90+
env {
91+
key = "PORT"
92+
value = var.env_var_port
93+
scope = "RUN_AND_BUILD_TIME"
94+
}
95+
96+
http_port = var.env_var_port
97+
98+
health_check {
99+
http_path = "/onebusaway-api-webapp/api/where/current-time.json?key=org.onebusaway.iphone"
100+
port = var.env_var_port
101+
}
102+
}
103+
}
104+
}

modules/digitalocean-ap/readme.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Deployment Guide for DigitalOcean App Platform
2+
3+
DigitalOcean App Platform is a platform-as-a-service (PaaS) that makes it easy to build, deploy, and scale apps quickly. This guide will walk you through deploying the OneBusAway server on DigitalOcean App Platform using Opentofu.
4+
5+
> [!WARNING]
6+
> Currently DigitalOcean App Platform's gVisor is conflicting with supervisor, they already know this issue and will fix it in the future.
7+
>
8+
> FYI: [App platform supervisor error](https://www.digitalocean.com/community/questions/app-platform-supervisor-error)
9+
10+
## Prerequisites
11+
12+
1. A [DigitalOcean](https://www.digitalocean.com/) account. If you don't have one, you can create an account [here](https://cloud.digitalocean.com/registrations/new).
13+
14+
2. A DigitalOcean API token, which you can generate from the [DigitalOcean Control Panel](https://cloud.digitalocean.com/account/api/tokens).
15+
16+
3. Opentofu, an open-source Terraform alternative. You can install it by following the instructions [here](https://opentofu.org/docs/intro/install/).
17+
18+
4. Ensure you have *ALL* the prerequisites installed before starting the deployment.
19+
20+
## Steps
21+
22+
1. Clone this repository to your local machine. You can run:
23+
24+
```bash
25+
git clone https://github.com/OneBusAway/onebusaway-deployment.git
26+
cd onebusaway-deployment/modules/digitalocean-ap
27+
```
28+
29+
2. Initialize the project. This will download the necessary plugins and providers for the project:
30+
31+
```bash
32+
tofu init
33+
```
34+
35+
3. Create a `terraform.tfvars` file by copying the example variables file, and then modify it according to your needs:
36+
37+
```bash
38+
cp terraform.tfvars.example terraform.tfvars
39+
```
40+
41+
4. Edit the `terraform.tfvars` file and update the variable values to match your specific requirements, such as your DigitalOcean API token, region, instance size, environment variables, and more.
42+
43+
5. Run Tofu plan to preview the infrastructure changes:
44+
45+
```bash
46+
tofu plan
47+
```
48+
49+
6. Apply the Tofu configuration to create the actual resources:
50+
51+
```bash
52+
tofu apply
53+
```
54+
55+
Type `yes` when prompted to confirm the resource creation.
56+
57+
7. After the deployment is complete, verify the created resources in the DigitalOcean Control Panel. Ensure the App Platform service, environment variables, and other related resources are created and running correctly.
58+
59+
8. Access the OneBusAway server by visiting the public URL of the App Platform service. You can find the service URL in the DigitalOcean Control Panel under the App Platform service details.
60+
61+
## Clean up
62+
63+
If you want to shut down the server and clean up the resources, you can run the following command:
64+
65+
```bash
66+
tofu destroy
67+
```
68+
69+
Opentofu will destroy all resources created by this project, including the DigitalOcean App Platform service and associated resources.
70+
71+
## Conclusion
72+
73+
This guide shows you how to deploy the OneBusAway server on DigitalOcean App Platform using Opentofu. If you have any questions or suggestions, feel free to open an issue in this repository.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
digitalocean_token = ""
2+
region = "nyc3"
3+
instance_size_slug = "basic-xxs"
4+
num_instances = 1
5+
6+
env_var_tz = "America/Toronto"
7+
env_var_gtfs_url = "https://api.cityofkingston.ca/gtfs/gtfs.zip"
8+
env_var_vehicle_positions_url = "https://api.cityofkingston.ca/gtfs-realtime/vehicleupdates.pb"
9+
env_var_trip_updates_url = "https://api.cityofkingston.ca/gtfs-realtime/tripupdates.pb"
10+
env_var_alerts_url = "https://api.cityofkingston.ca/gtfs-realtime/alerts.pb"
11+
env_var_feed_api_key = ""
12+
env_var_feed_api_value = ""
13+
env_var_refresh_interval = 30
14+
env_var_agency_id = "0"
15+
env_var_jdbc_user = "oba_user"
16+
env_var_jdbc_password = "oba_password"
17+
env_var_jdbc_url = "jdbc:mysql://<DATABASE_HOST>:<PORT>/oba_database"
18+
env_var_port = 8080

modules/digitalocean-ap/variables.tf

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
variable "digitalocean_token" {
2+
description = "DigitalOcean API Token"
3+
type = string
4+
}
5+
6+
variable "region" {
7+
description = "The slug for the DigitalOcean data center region hosting the app."
8+
type = string
9+
default = "nyc3"
10+
}
11+
12+
variable "instance_size_slug" {
13+
description = "The instance size to use for this component. This determines the plan (basic or professional) and the available CPU and memory. "
14+
type = string
15+
default = "basic-xxs"
16+
}
17+
18+
variable "num_instances" {
19+
description = "Number of instances"
20+
type = number
21+
default = 1
22+
}
23+
24+
variable "env_var_tz" {
25+
description = "Timezone"
26+
type = string
27+
}
28+
29+
variable "env_var_gtfs_url" {
30+
description = "GTFS URL"
31+
type = string
32+
}
33+
34+
variable "env_var_vehicle_positions_url" {
35+
description = "Vehicle positions URL"
36+
type = string
37+
}
38+
39+
variable "env_var_trip_updates_url" {
40+
description = "Trip updates URL"
41+
type = string
42+
}
43+
44+
variable "env_var_alerts_url" {
45+
description = "Alerts URL"
46+
type = string
47+
}
48+
49+
variable "env_var_feed_api_key" {
50+
description = "Feed API Key"
51+
type = string
52+
}
53+
54+
variable "env_var_feed_api_value" {
55+
description = "Feed API Value"
56+
type = string
57+
}
58+
59+
variable "env_var_refresh_interval" {
60+
description = "Refresh interval"
61+
type = number
62+
default = 30
63+
}
64+
65+
variable "env_var_agency_id" {
66+
description = "Agency ID"
67+
type = string
68+
}
69+
70+
variable "env_var_jdbc_user" {
71+
description = "JDBC User"
72+
type = string
73+
}
74+
75+
variable "env_var_jdbc_password" {
76+
description = "JDBC Password"
77+
type = string
78+
}
79+
80+
variable "env_var_jdbc_url" {
81+
description = "JDBC URL"
82+
type = string
83+
}
84+
85+
variable "env_var_port" {
86+
description = "Port"
87+
type = number
88+
default = 8080
89+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GTFS_URL=https://api.cityofkingston.ca/gtfs/gtfs.zip
2+
TEST_API_KEY=test
3+
VEHICLE_POSITIONS_URL=https://api.cityofkingston.ca/gtfs-realtime/vehicleupdates.pb
4+
TRIP_UPDATES_URL=https://api.cityofkingston.ca/gtfs-realtime/tripupdates.pb
5+
ALERTS_URL=https://api.cityofkingston.ca/gtfs-realtime/alerts.pb
6+
REFRESH_INTERVAL=30
7+
AGENCY_ID=0
8+
TZ=America/Toronto
9+
GOOGLE_MAPS_API_KEY=<YOUR_GOOGLE_MAPS_API_KEY>
10+
GOOGLE_MAPS_CHANNEL_ID=<YOUR_GOOGLE_MAPS_CHANNEL_ID>
11+
GOOGLE_MAPS_CLIENT_ID=<YOUR_GOOGLE_MAPS_CLIENT_ID>
12+
# Your Domain Name, leave blank if you don't have one
13+
DOMAIN=oba.example.com
14+
# OBA image version. You can find the available versions at:
15+
# https://hub.docker.com/r/opentransitsoftwarefoundation/onebusaway-api-webapp/tags
16+
OBA_VERSION=latest

0 commit comments

Comments
 (0)