-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
paas: add deployment on Render and DigitalOcean
- Loading branch information
Showing
22 changed files
with
922 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
terraform { | ||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = "~> 2.0" | ||
} | ||
} | ||
} | ||
|
||
provider "digitalocean" { | ||
token = var.digitalocean_token | ||
} | ||
|
||
resource "digitalocean_app" "main" { | ||
spec { | ||
name = "onebusaway-api-server" | ||
region = var.region | ||
|
||
service { | ||
name = "onebusaway-api-webapp" | ||
image { | ||
registry_type = "DOCKER_HUB" | ||
registry = "opentransitsoftwarefoundation" | ||
repository = "onebusaway-api-webapp" | ||
tag = "2.5.12-cs-v1.0.0" | ||
} | ||
instance_size_slug = var.instance_size_slug | ||
instance_count = var.num_instances | ||
|
||
env { | ||
key = "TZ" | ||
value = var.env_var_tz | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "GTFS_URL" | ||
value = var.env_var_gtfs_url | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "VEHICLE_POSITIONS_URL" | ||
value = var.env_var_vehicle_positions_url | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "TRIP_UPDATES_URL" | ||
value = var.env_var_trip_updates_url | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "ALERTS_URL" | ||
value = var.env_var_alerts_url | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "FEED_API_KEY" | ||
value = var.env_var_feed_api_key | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "FEED_API_VALUE" | ||
value = var.env_var_feed_api_value | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "REFRESH_INTERVAL" | ||
value = var.env_var_refresh_interval | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "AGENCY_ID" | ||
value = var.env_var_agency_id | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "JDBC_USER" | ||
value = var.env_var_jdbc_user | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "JDBC_PASSWORD" | ||
value = var.env_var_jdbc_password | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "JDBC_URL" | ||
value = var.env_var_jdbc_url | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
env { | ||
key = "PORT" | ||
value = var.env_var_port | ||
scope = "RUN_AND_BUILD_TIME" | ||
} | ||
|
||
http_port = var.env_var_port | ||
|
||
health_check { | ||
http_path = "/onebusaway-api-webapp/api/where/current-time.json?key=org.onebusaway.iphone" | ||
port = var.env_var_port | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Deployment Guide for DigitalOcean App Platform | ||
|
||
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. | ||
|
||
> [!WARNING] | ||
> Currently DigitalOcean App Platform's gVisor is conflicting with supervisor, they already know this issue and will fix it in the future. | ||
> | ||
> FYI: [App platform supervisor error](https://www.digitalocean.com/community/questions/app-platform-supervisor-error) | ||
## Prerequisites | ||
|
||
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). | ||
|
||
2. A DigitalOcean API token, which you can generate from the [DigitalOcean Control Panel](https://cloud.digitalocean.com/account/api/tokens). | ||
|
||
3. Opentofu, an open-source Terraform alternative. You can install it by following the instructions [here](https://opentofu.org/docs/intro/install/). | ||
|
||
4. Ensure you have *ALL* the prerequisites installed before starting the deployment. | ||
|
||
## Steps | ||
|
||
1. Clone this repository to your local machine. You can run: | ||
|
||
```bash | ||
git clone https://github.com/OneBusAway/onebusaway-deployment.git | ||
cd onebusaway-deployment/modules/digitalocean-ap | ||
``` | ||
|
||
2. Initialize the project. This will download the necessary plugins and providers for the project: | ||
|
||
```bash | ||
tofu init | ||
``` | ||
|
||
3. Create a `terraform.tfvars` file by copying the example variables file, and then modify it according to your needs: | ||
|
||
```bash | ||
cp terraform.tfvars.example terraform.tfvars | ||
``` | ||
|
||
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. | ||
|
||
5. Run Tofu plan to preview the infrastructure changes: | ||
|
||
```bash | ||
tofu plan | ||
``` | ||
|
||
6. Apply the Tofu configuration to create the actual resources: | ||
|
||
```bash | ||
tofu apply | ||
``` | ||
|
||
Type `yes` when prompted to confirm the resource creation. | ||
|
||
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. | ||
|
||
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. | ||
|
||
## Clean up | ||
|
||
If you want to shut down the server and clean up the resources, you can run the following command: | ||
|
||
```bash | ||
tofu destroy | ||
``` | ||
|
||
Opentofu will destroy all resources created by this project, including the DigitalOcean App Platform service and associated resources. | ||
|
||
## Conclusion | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
digitalocean_token = "" | ||
region = "nyc3" | ||
instance_size_slug = "basic-xxs" | ||
num_instances = 1 | ||
|
||
env_var_tz = "America/Toronto" | ||
env_var_gtfs_url = "https://api.cityofkingston.ca/gtfs/gtfs.zip" | ||
env_var_vehicle_positions_url = "https://api.cityofkingston.ca/gtfs-realtime/vehicleupdates.pb" | ||
env_var_trip_updates_url = "https://api.cityofkingston.ca/gtfs-realtime/tripupdates.pb" | ||
env_var_alerts_url = "https://api.cityofkingston.ca/gtfs-realtime/alerts.pb" | ||
env_var_feed_api_key = "" | ||
env_var_feed_api_value = "" | ||
env_var_refresh_interval = 30 | ||
env_var_agency_id = "0" | ||
env_var_jdbc_user = "oba_user" | ||
env_var_jdbc_password = "oba_password" | ||
env_var_jdbc_url = "jdbc:mysql://<DATABASE_HOST>:<PORT>/oba_database" | ||
env_var_port = 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
variable "digitalocean_token" { | ||
description = "DigitalOcean API Token" | ||
type = string | ||
} | ||
|
||
variable "region" { | ||
description = "The slug for the DigitalOcean data center region hosting the app." | ||
type = string | ||
default = "nyc3" | ||
} | ||
|
||
variable "instance_size_slug" { | ||
description = "The instance size to use for this component. This determines the plan (basic or professional) and the available CPU and memory. " | ||
type = string | ||
default = "basic-xxs" | ||
} | ||
|
||
variable "num_instances" { | ||
description = "Number of instances" | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "env_var_tz" { | ||
description = "Timezone" | ||
type = string | ||
} | ||
|
||
variable "env_var_gtfs_url" { | ||
description = "GTFS URL" | ||
type = string | ||
} | ||
|
||
variable "env_var_vehicle_positions_url" { | ||
description = "Vehicle positions URL" | ||
type = string | ||
} | ||
|
||
variable "env_var_trip_updates_url" { | ||
description = "Trip updates URL" | ||
type = string | ||
} | ||
|
||
variable "env_var_alerts_url" { | ||
description = "Alerts URL" | ||
type = string | ||
} | ||
|
||
variable "env_var_feed_api_key" { | ||
description = "Feed API Key" | ||
type = string | ||
} | ||
|
||
variable "env_var_feed_api_value" { | ||
description = "Feed API Value" | ||
type = string | ||
} | ||
|
||
variable "env_var_refresh_interval" { | ||
description = "Refresh interval" | ||
type = number | ||
default = 30 | ||
} | ||
|
||
variable "env_var_agency_id" { | ||
description = "Agency ID" | ||
type = string | ||
} | ||
|
||
variable "env_var_jdbc_user" { | ||
description = "JDBC User" | ||
type = string | ||
} | ||
|
||
variable "env_var_jdbc_password" { | ||
description = "JDBC Password" | ||
type = string | ||
} | ||
|
||
variable "env_var_jdbc_url" { | ||
description = "JDBC URL" | ||
type = string | ||
} | ||
|
||
variable "env_var_port" { | ||
description = "Port" | ||
type = number | ||
default = 8080 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
GTFS_URL=https://api.cityofkingston.ca/gtfs/gtfs.zip | ||
TEST_API_KEY=test | ||
VEHICLE_POSITIONS_URL=https://api.cityofkingston.ca/gtfs-realtime/vehicleupdates.pb | ||
TRIP_UPDATES_URL=https://api.cityofkingston.ca/gtfs-realtime/tripupdates.pb | ||
ALERTS_URL=https://api.cityofkingston.ca/gtfs-realtime/alerts.pb | ||
REFRESH_INTERVAL=30 | ||
AGENCY_ID=0 | ||
TZ=America/Toronto | ||
GOOGLE_MAPS_API_KEY=<YOUR_GOOGLE_MAPS_API_KEY> | ||
GOOGLE_MAPS_CHANNEL_ID=<YOUR_GOOGLE_MAPS_CHANNEL_ID> | ||
GOOGLE_MAPS_CLIENT_ID=<YOUR_GOOGLE_MAPS_CLIENT_ID> | ||
# Your Domain Name, leave blank if you don't have one | ||
DOMAIN=oba.example.com | ||
# OBA image version. You can find the available versions at: | ||
# https://hub.docker.com/r/opentransitsoftwarefoundation/onebusaway-api-webapp/tags | ||
OBA_VERSION=latest |
Oops, something went wrong.