OneBusAway / onebusaway-docker

Docker configuration for the OneBusAway Application Modules (https://github.com/OneBusAway/onebusaway-application-modules)
Apache License 2.0
18 stars 32 forks source link

feat: add support to GTFS-RT auth header #59

Closed Altonhe closed 7 months ago

Altonhe commented 7 months ago

Support for authentication headers in GTFS-RT feeds has been added, you can test it with

version: "3"

services:
  oba_bundler:
    build: ./bundler
    volumes:
      - ./bundle:/bundle
    environment:
      - GTFS_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_Data.zip

  oba_database:
    image: mysql:8.3
    container_name: oba_database
    environment:
      MYSQL_ROOT_PASSWORD: Ins3cure!
      MYSQL_DATABASE: oba_database
      MYSQL_USER: oba_user
      MYSQL_PASSWORD: oba_password
    ports:
      - "3306:3306"
    volumes:
      - type: volume
        source: mysql-data
        target: /var/lib/mysql
    restart: always

  oba_app:
    container_name: oba_app
    depends_on:
      - oba_database
    build:
      context: ./oba
      # For test only, remove in production
      args:
        - TEST_API_KEY=test
        - VEHICLE_POSITIONS_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_VehiclePositions.pb
        - TRIP_UPDATES_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_TripUpdates.pb
        - ALERTS_URL=https://opendata.burlington.ca/gtfs-rt/GTFS_ServiceAlerts.pb
        - REFRESH_INTERVAL=30
        - AGENCY_ID=Burlington
        - FEED_API_KEY=x-api-key
        - FEED_API_VALUE=1234567890abcdef
    environment:
      - JDBC_URL=jdbc:mysql://oba_database:3306/oba_database
      - JDBC_USER=oba_user
      - JDBC_PASSWORD=oba_password
    volumes:
      # Share the host's `bundle` directory
      # with the filesystem of the OBA service.
      - ./bundle:/bundle
    ports:
      # Access the webapp on your host machine at a path like
      # http://localhost:8080/onebusaway-api-webapp/api/where/agency/${YOUR_AGENCY}.json?key=TEST
      - "8080:8080"
    # restart: always

volumes:
  mysql-data:

Results:

 $ cat /usr/local/tomcat/webapps/onebusaway-transit-data-federation-webapp/WEB-INF/classes/data-sources.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context-3.0.xsd">
  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
    <property name="url" value="${JDBC_URL}"/>
    <property name="username" value="${JDBC_USER}"/>
    <property name="password" value="${JDBC_PASSWORD}"/>
  </bean>
  <bean class="org.onebusaway.container.spring.SystemPropertyOverrideConfigurer">
    <property name="order" value="-2"/>
    <property name="properties">
      <props>
        <prop key="bundleStoreRoot">/bundle</prop>
      </props>
    </property>
  </bean>
  <bean id="httpServiceClient" class="org.onebusaway.transit_data_federation.util.HttpServiceClientImpl">
    <constructor-arg type="java.lang.String" value="localhost"/>
    <constructor-arg type="java.lang.Integer" value="8080"/>
    <constructor-arg type="java.lang.String" value="/onebusaway-admin-webapp/api/"/>
  </bean>
  <!--    GTFS-RT related beans, automatically generated by the `bootstrap.sh`-->
  <bean id="gtfsRT" class="org.onebusaway.transit_data_federation.impl.realtime.gtfs_realtime.GtfsRealtimeSource">
    <property name="tripUpdatesUrl" value="https://opendata.burlington.ca/gtfs-rt/GTFS_TripUpdates.pb"/>
    <property name="vehiclePositionsUrl" value="https://opendata.burlington.ca/gtfs-rt/GTFS_VehiclePositions.pb"/>
    <property name="alertsUrl" value="https://opendata.burlington.ca/gtfs-rt/GTFS_ServiceAlerts.pb"/>
    <property name="refreshInterval" value="30"/>
    <property name="agencyId" value="Burlington"/>
    <property name="headersMap">
      <map>
        <entry key="x-api-key" value="1234567890abcdef"/>
      </map>
    </property>
  </bean>
  <bean id="bundleManagementService" class="org.onebusaway.transit_data_federation.impl.bundle.BundleManagementServiceImpl">
    <property name="bundleStoreRoot" value="/bundle"/>
    <property name="standaloneMode" value="true"/>
  </bean>
</beans>