Skip to content

Latest commit

 

History

History
141 lines (97 loc) · 4.09 KB

README.md

File metadata and controls

141 lines (97 loc) · 4.09 KB

GTFS Validator Web Service

Setup

  • Create GCP Account
  • Create Google Cloud bucket for uploads
  • Create Google Cloud bucket for reports/results

The current instance is currnetly configured with the following:

  • Upload Bucket: gs://gtfs-validator-user-uploads
  • Results Bucket: gs://gs://gtfs-validator-results
  • Set default region
gcloud config set run/region us-east1
  • Service account for invoker
gcloud iam service-accounts create invoker-gtfs-web \
   --display-name "Invoker for gtfs web pub/sub"
  • Grant permissions
gcloud run services add-iam-policy-binding gtfs-validator-web \
   --member=serviceAccount:invoker-gtfs-web@web-based-gtfs-validator.iam.gserviceaccount.com \
   --role=roles/run.invoker
  • Create pub/sub topic
gcloud pubsub topics create GTFS-WEB-VALIDATOR
  • Create a push subscription and associate it with the service account
gcloud projects add-iam-policy-binding web-based-gtfs-validator \
     --member=serviceAccount:[email protected] \
     --role=roles/iam.serviceAccountTokenCreator
  • Create a Pub/Sub subscription with the service account
gcloud pubsub subscriptions create GTFS-WEB-VALIDATOR-SUBSCRIPTION --topic GTFS-WEB-VALIDATOR \
--ack-deadline=600 \
--push-endpoint=https://gtfs-validator-web-mbzoxaljzq-ue.a.run.app/run-validator \
--push-auth-service-account=invoker-gtfs-web@web-based-gtfs-validator.iam.gserviceaccount.com
  • Test
gcloud pubsub topics publish GTFS-WEB-VALIDATOR --message "hello"
  • Apply notification configuration
gcloud storage buckets notifications create gs://gtfs-validator-user-uploads --topic=GTFS-WEB-VALIDATOR --event-types=OBJECT_FINALIZE

CORS setup for upload bucket

[
  {
    "origin": ["*"],
    "method": ["PUT"],
    "responseHeader": ["content-type", "access-control-allow-origin"],
    "maxAgeSeconds": 3600
  }
]
gcloud storage buckets update gs://gtfs-validator-user-uploads --cors-file=cors.json

CORS setup for reports bucket

[
  {
    "origin": ["*"],
    "method": ["HEAD", "GET"],
    "responseHeader": ["content-type", "access-control-allow-origin"],
    "maxAgeSeconds": 3600
  }
]
gcloud storage buckets update gs://gtfs-validator-results --cors-file=cors.json

Google Cloud Storage Bucket Lifecycle

Both gtfs-validator-user-uploads and gtfs-validator-results have been configured so that all files older than 30 days are deleted. This can be manually configured via the Google Cloud Storage Console or via the CLI.

Local Development

A google cloud credentials file is requierd to start the web service. Either complete the steps above to provision a new Google Cloud project or reach out to the maintainers of the project to be granted access to the production instance credentials.

The location of credential key file is located in web/service/src/main/resources/application.properties.

Once this is completed, the server can be started by running ./gradlew bootRun in the root of the project.

Note: The web/service/src/test/resources/web-based-gtfs-validator.json contains a valid primary key, but it is not tied to a valid Google Cloud Service Account.

Start the client (from the web/client directory):

npm run dev

Deploying Updates

First install the gcloud cli and authenticate.

gcloud builds submit

Open API Spec

⚠️ Subject to change: This API spec may change at any time. We do not reccomend building any production systems that depend on this API directly.

Open API Spec V3 documentation is avaliable at web/service/open-api-spec.json.