diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0553c35..b0f9196 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -70,6 +70,9 @@ jobs: services_standalone: name: Services standalone runs-on: ubuntu-latest + permissions: + id-token: write + contents: read steps: - name: Checkout code uses: actions/checkout@v4 @@ -90,6 +93,13 @@ jobs: chmod +x ./bin/validate.sh ./bin/validate.sh + # - name: Breakpoint if tests failed + # if: failure() + # uses: namespacelabs/breakpoint-action@v0 + # with: + # duration: 30m + # authorized-users: aaronbrethorst + - name: Docker Compose down if: always() run: docker compose down \ No newline at end of file diff --git a/README.md b/README.md index 8d1868c..5eb7620 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ To build bundles and run the webapp server with your own GTFS feed, use the [Doc The app server and bundle builder use Maven artifacts from GitHub's Maven package registry, which unfortunately requires authentication. This is provided in the form of a pair of environment variables that must be supplied when building the app server image: ```bash -PAT_USERNAME_FOR_GH=GITHUB_USERNAME \ PAT_TOKEN_FOR_GH=GITHUB_PERSONAL_ACCESS_TOKEN \ +PAT_USERNAME_FOR_GH=GITHUB_USERNAME \ +PAT_TOKEN_FOR_GH=GITHUB_PERSONAL_ACCESS_TOKEN \ docker compose build oba_app ``` @@ -41,7 +42,8 @@ To build a bundle, use the `oba_bundler` service: ```bash GTFS_URL=https://www.soundtransit.org/GTFS-rail/40_gtfs.zip \ -PAT_USERNAME_FOR_GH=GITHUB_USERNAME \ PAT_TOKEN_FOR_GH=GITHUB_PERSONAL_ACCESS_TOKEN \ +PAT_USERNAME_FOR_GH=GITHUB_USERNAME \ +PAT_TOKEN_FOR_GH=GITHUB_PERSONAL_ACCESS_TOKEN \ docker compose up oba_bundler ``` @@ -61,11 +63,10 @@ Once you have built an OBA bundle inside `./bundle`, you can run the OBA server docker compose up oba_app ``` -You will then have three web apps available: +You will then have two web apps available: * onebusaway-api-webapp, hosted at http://localhost:8080/onebusaway-api-webapp * Example API call: http://localhost:8080/onebusaway-api-webapp/api/where/agencies-with-coverage.json?key=TEST -* onebusaway-enterprise-acta-webapp, a user-facing web app: http://localhost:8080 * onebusaway-transit-data-federation-webapp, which does the heavy lifting of exposing the transit data bundle to other services: http://localhost:8080/onebusaway-transit-data-federation-webapp When done using this web server, you can use the shell-standard `^C` to exit out and turn it off. If issues persist across runs, you can try using `docker compose down -v` and then `docker compose up oba_app` to refresh the Docker containers and services. @@ -112,7 +113,7 @@ You can find the latest published Docker images on Docker Hub: -The `GTFS-RT` and `Google Map` related variables will be handled by the `oba/bootstrap.sh` script, which will set the config files for the OBA API webapp. If you want to use your own config files, you could set `USER_CONFIGURED=1` in the `oba_app` service in `docker-compose.yml` to skip `bootstrap.sh` and write your config file in the container. +The `GTFS-RT` related variables will be handled by the `oba/bootstrap.sh` script, which will set the config files for the OBA API webapp. If you want to use your own config files, you could set `USER_CONFIGURED=1` in the `oba_app` service in `docker-compose.yml` to skip `bootstrap.sh` and write your config file in the container. ```yaml oba_app: container_name: oba_app @@ -130,41 +131,3 @@ The `GTFS-RT` and `Google Map` related variables will be handled by the `oba/boo # skip bootstrap.sh and use user-configured config files - USER_CONFIGURED=1 ``` - -### Using Google Maps - -#### Prerequisites - -- Have a valid Google Cloud Platform (GCP) account. -- Create a project on GCP and enable the Maps JavaScript API for it. -- Create an API key for your project. [See how to create an API key](https://cloud.google.com/docs/authentication/api-keys). -- If there is a rate limit error while using the test API key, it means you have reached the maximum usage limit for that key, you need to generate a new API key. - -#### Configuring Google Maps - -You'll need to set the following environment variables: - -- `GOOGLE_MAPS_API_KEY`: Your Google Maps API key. -- `GOOGLE_MAPS_CLIENT_ID`: (Optional) Required if you are using the Google Maps Premium Plan. -- `GOOGLE_MAPS_CHANNEL_ID`: (Optional) A channel ID that helps identify the source of API requests for analytics and reporting purposes. - -#### Docker Configuration - -If using Docker Compose: - -1.Modify the 'docker-compose.yml' file like this: - -```yaml -services: - oba-app: - environment: - - GOOGLE_MAPS_API_KEY= - - GOOGLE_MAPS_CHANNEL_ID= - - GOOGLE_MAPS_CLIENT_ID= -``` - -2.Use the following command to start the oba-app service: - -```bash -docker compose up -d oba-app -``` diff --git a/bin/validate.sh b/bin/validate.sh index 7e37b24..d05b435 100755 --- a/bin/validate.sh +++ b/bin/validate.sh @@ -1,6 +1,6 @@ #!/bin/bash -output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/current-time.json?key=test" | jq '.data.entry.time') +output=$(curl -s "http://localhost:8080/api/where/current-time.json?key=test" | jq '.data.entry.time') if [[ ! -z "$output" && "$output" =~ ^[0-9]+$ ]]; then echo "current-time.json endpoint works." @@ -9,7 +9,7 @@ else exit 1 fi -output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/agencies-with-coverage.json?key=test" | jq '.data.list[0].agencyId') +output=$(curl -s "http://localhost:8080/api/where/agencies-with-coverage.json?key=test" | jq '.data.list[0].agencyId') if [[ ! -z "$output" && "$output" == "\"unitrans\"" ]]; then echo "agencies-with-coverage.json endpoint works." @@ -18,7 +18,7 @@ else exit 1 fi -output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/routes-for-agency/unitrans.json?key=test" | jq '.data.list | length') +output=$(curl -s "http://localhost:8080/api/where/routes-for-agency/unitrans.json?key=test" | jq '.data.list | length') if [[ $output -gt 10 ]]; then echo "routes-for-agency/unitrans.json endpoint works." else @@ -26,7 +26,7 @@ else exit 1 fi -output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/stops-for-route/unitrans_C.json?key=test" | jq '.data.entry.routeId') +output=$(curl -s "http://localhost:8080/api/where/stops-for-route/unitrans_C.json?key=test" | jq '.data.entry.routeId') if [[ ! -z "$output" && "$output" == "\"unitrans_C\"" ]]; then echo "stops-for-route/unitrans_C.json endpoint works." else @@ -34,7 +34,7 @@ else exit 1 fi -output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/stop/unitrans_22182.json?key=test" | jq '.data.entry.code') +output=$(curl -s "http://localhost:8080/api/where/stop/unitrans_22182.json?key=test" | jq '.data.entry.code') if [[ ! -z "$output" && "$output" == "\"22182\"" ]]; then echo "stop/unitrans_22182.json endpoint works." else @@ -42,7 +42,7 @@ else exit 1 fi -output=$(curl -s "http://localhost:8080/onebusaway-api-webapp/api/where/stops-for-location.json?lat=38.555308&lon=-121.735991&key=test" | jq '.data.outOfRange') +output=$(curl -s "http://localhost:8080/api/where/stops-for-location.json?lat=38.555308&lon=-121.735991&key=test" | jq '.data.outOfRange') if [[ ! -z "$output" && "$output" == "false" ]]; then echo "stops-for-location/unitrans_false.json endpoint works." else @@ -50,15 +50,6 @@ else exit 1 fi -output=$(curl -s "http://localhost:8080/") -if echo "$output" | grep -qi "onebusaway enterprise"; then - echo "Success: webapp found on http://localhost:8080" -else - echo "Error: webapp NOT found on http://localhost:8080" - echo $output - exit 1 -fi - # todo: add support for arrivals-and-departures-for-stop endpoint. # however, it doesn't seem that the unitrans_22182 stop has arrivals and departures on the weekend, so we'll need # something else to test with. However, for now, this is still a great step forward. \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index e3d5846..e0748dd 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -50,7 +50,6 @@ services: - ALERTS_URL - REFRESH_INTERVAL=30 - AGENCY_ID - - GOOGLE_MAPS_API_KEY volumes: # Share the host"s `bundle` directory diff --git a/k8s-readme.md b/k8s-readme.md index beb1652..ca5f6aa 100644 --- a/k8s-readme.md +++ b/k8s-readme.md @@ -43,23 +43,3 @@ Then you can connect to it programmatically using `mysql`: ```bash mysql -u oba_user -p -h localhost:3306 ``` - -#### Google Maps - - -If deployed in Kubernetes environment: - -1. Use the kubectl set env command to set new environment variables, -make sure you replace deployment/oba-app with the actual name of your deployment: - -```bash -kubectl set env deployment/oba-app GOOGLE_MAPS_API_KEY= \ - GOOGLE_MAPS_CHANNEL_ID= \ - GOOGLE_MAPS_CLIENT_ID= -``` - -2. Use the following command to rebuild and start the oba app service: - -```bash -kubectl rollout restart deployment/oba-app -``` diff --git a/oba/Dockerfile b/oba/Dockerfile index d5e96fc..2475dfd 100644 --- a/oba/Dockerfile +++ b/oba/Dockerfile @@ -94,9 +94,7 @@ COPY --from=builder \ WORKDIR /oba/config COPY ./config/context.xml.hbs . -COPY ./config/googlemaps.config.json.hbs . COPY ./config/onebusaway-api-webapp-data-sources.xml.hbs . -COPY ./config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs . COPY ./config/onebusaway-transit-data-federation-webapp-data-sources.xml.hbs . ########## @@ -105,42 +103,27 @@ COPY ./config/onebusaway-transit-data-federation-webapp-data-sources.xml.hbs . WORKDIR $CATALINA_HOME/webapps -########## -# Configure onebusaway-api-webapp -########## - -COPY --from=builder \ - --chown=oba_user:oba_group \ - /oba/libs/onebusaway-api-webapp.war . - -RUN mkdir onebusaway-api-webapp && \ - cd onebusaway-api-webapp && \ - jar xvf ../onebusaway-api-webapp.war && \ - rm ../onebusaway-api-webapp.war - -COPY --from=builder \ - --chown=oba_user:oba_group \ - /oba/libs/mysql-connector-j.jar onebusaway-api-webapp/WEB-INF/lib/ +# COPY --from=builder \ +# --chown=oba_user:oba_group \ +# /oba/libs/postgresql.jar \ +# $CATALINA_HOME/webapps/ROOT/WEB-INF/lib/ -COPY --from=builder \ - --chown=oba_user:oba_group \ - /oba/libs/postgresql.jar onebusaway-api-webapp/WEB-INF/lib/ +# COPY ./config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs \ +# $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/data-sources.xml.hbs -COPY ./config/onebusaway-api-webapp-data-sources.xml.hbs \ - $CATALINA_HOME/webapps/onebusaway-api-webapp/WEB-INF/classes/data-sources.xml.hbs ########## -# Configure onebusaway-enterprise-acta-webapp as ROOT (i.e. the path `/`) +# Configure onebusaway-api-webapp ########## COPY --from=builder \ --chown=oba_user:oba_group \ - /oba/libs/onebusaway-enterprise-acta-webapp.war . + /oba/libs/onebusaway-api-webapp.war . RUN mkdir ROOT && \ cd ROOT && \ - jar xvf ../onebusaway-enterprise-acta-webapp.war && \ - rm ../onebusaway-enterprise-acta-webapp.war + jar xvf ../onebusaway-api-webapp.war && \ + rm ../onebusaway-api-webapp.war COPY --from=builder \ --chown=oba_user:oba_group \ @@ -152,11 +135,9 @@ COPY --from=builder \ /oba/libs/postgresql.jar \ $CATALINA_HOME/webapps/ROOT/WEB-INF/lib/ -COPY ./config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs \ - $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/data-sources.xml.hbs - +COPY ./config/onebusaway-api-webapp-data-sources.xml.hbs \ + $CATALINA_HOME/webapps/onebusaway-api-webapp/WEB-INF/classes/data-sources.xml.hbs -# TODO: when/where/why is this needed? RUN mkdir -p /opt/oba/logs RUN chown -R oba_user:oba_group /opt/oba/logs RUN chmod 755 /opt/oba/logs diff --git a/oba/bootstrap.sh b/oba/bootstrap.sh index 47cc660..b9c83ed 100644 --- a/oba/bootstrap.sh +++ b/oba/bootstrap.sh @@ -26,7 +26,7 @@ fi ##### API_XML_SOURCE="/oba/config/onebusaway-api-webapp-data-sources.xml.hbs" -API_XML_DESTINATION="$CATALINA_HOME/webapps/onebusaway-api-webapp/WEB-INF/classes/data-sources.xml" +API_XML_DESTINATION="$CATALINA_HOME/webapps/ROOT/WEB-INF/classes/data-sources.xml" hbs_renderer -input "$API_XML_SOURCE" \ -json '{"TEST_API_KEY": "'$TEST_API_KEY'", "JDBC_DRIVER": "'$JDBC_DRIVER'"}' \ @@ -58,35 +58,6 @@ hbs_renderer -input "$FEDERATION_XML_SOURCE" \ -json '{"GTFS_RT_AVAILABLE": "'$GTFS_RT_AVAILABLE'", "TRIP_UPDATES_URL": "'$TRIP_UPDATES_URL'", "VEHICLE_POSITIONS_URL": "'$VEHICLE_POSITIONS_URL'", "ALERTS_URL": "'$ALERTS_URL'", "REFRESH_INTERVAL": "'$REFRESH_INTERVAL'", "AGENCY_ID": "'$AGENCY_ID'", "HAS_API_KEY": "'$HAS_API_KEY'", "FEED_API_KEY": "'$FEED_API_KEY'", "FEED_API_VALUE": "'$FEED_API_VALUE'"}' \ -output "$FEDERATION_XML_DESTINATION" -##### -# onebusaway-enterprise-acta-webapp -##### - -# Google map related environment variables -WEBAPP_XML_SOURCE="/oba/config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs" -WEBAPP_XML_DESTINATION="$CATALINA_HOME/webapps/ROOT/WEB-INF/classes/data-sources.xml" - -if [ -z "$GOOGLE_MAPS_API_KEY" ] && [ -z "$GOOGLE_MAPS_CLIENT_ID" ] && [ -z "$GOOGLE_MAPS_CHANNEL_ID" ]; then - echo "No Google Maps related environment variables are set. Removing element from data-sources.xml" - GOOGLE_MAPS_CONFIGURED="" -else - echo "Google Maps related environment variables are set. Setting them in data-sources.xml" - GOOGLE_MAPS_CONFIGURED="1" - - MAP_CONFIG_SOURCE="/oba/config/googlemaps.config.json.hbs" - MAP_CONFIG_DESTINATION="/var/lib/oba/config.json" - - mkdir -p $(dirname "$MAP_CONFIG_DESTINATION") - - hbs_renderer -input "$MAP_CONFIG_SOURCE" \ - -json '{"GOOGLE_MAPS_CONFIGURED": "'$GOOGLE_MAPS_CONFIGURED'", "GOOGLE_MAPS_API_KEY": "'$GOOGLE_MAPS_API_KEY'", "GOOGLE_MAPS_CLIENT_ID": "'$GOOGLE_MAPS_CLIENT_ID'", "GOOGLE_MAPS_CHANNEL_ID": "'$GOOGLE_MAPS_CHANNEL_ID'"}' \ - -output "$MAP_CONFIG_DESTINATION" -fi - -hbs_renderer -input "$WEBAPP_XML_SOURCE" \ - -json '{"GOOGLE_MAPS_CONFIGURED": "'$GOOGLE_MAPS_CONFIGURED'"}' \ - -output "$WEBAPP_XML_DESTINATION" - ##### # Tomcat context.xml ##### diff --git a/oba/config/googlemaps.config.json.hbs b/oba/config/googlemaps.config.json.hbs deleted file mode 100644 index 0b3e594..0000000 --- a/oba/config/googlemaps.config.json.hbs +++ /dev/null @@ -1,9 +0,0 @@ -{ - "config":[ - {{#if GOOGLE_MAPS_CONFIGURED}} - {"component": "display", "key": "display.googleMapsApiKey", "value": "{{GOOGLE_MAPS_API_KEY}}"}, - {"component": "display", "key": "display.googleMapsClientId", "value": "{{GOOGLE_MAPS_CLIENT_ID}}"}, - {"component": "display", "key": "display.googleMapsChannelId", "value": "{{GOOGLE_MAPS_CHANNEL_ID}}"} - {{/if}} - ] -} \ No newline at end of file diff --git a/oba/config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs b/oba/config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs deleted file mode 100644 index 906020b..0000000 --- a/oba/config/onebusaway-enterprise-acta-webapp-data-sources.xml.hbs +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - {{#if GOOGLE_MAPS_CONFIGURED}} - - - - {{/if}} - - - - - - - - - - - - - - - - - - - - - - - org.onebusaway.onebusaway-enterprise-acta-webapp.cacheManager - - - - - - - - \ No newline at end of file diff --git a/oba/config/pom.xml b/oba/config/pom.xml index ee07ca4..f1a779b 100644 --- a/oba/config/pom.xml +++ b/oba/config/pom.xml @@ -28,12 +28,6 @@ ${OBA_VERSION} war - - org.onebusaway - onebusaway-enterprise-acta-webapp - ${OBA_VERSION} - war - org.onebusaway onebusaway-transit-data-federation-webapp diff --git a/oba/retrieve_maven_artifacts.sh b/oba/retrieve_maven_artifacts.sh index 50e5416..9289a00 100644 --- a/oba/retrieve_maven_artifacts.sh +++ b/oba/retrieve_maven_artifacts.sh @@ -31,10 +31,6 @@ copy_and_rename_artifact \ "org.onebusaway:onebusaway-api-webapp:${OBA_VERSION}:war" \ "onebusaway-api-webapp" -copy_and_rename_artifact \ - "org.onebusaway:onebusaway-enterprise-acta-webapp:${OBA_VERSION}:war" \ - "onebusaway-enterprise-acta-webapp" - copy_and_rename_artifact \ "org.onebusaway:onebusaway-transit-data-federation-webapp:${OBA_VERSION}:war" \ "onebusaway-transit-data-federation-webapp"