Before, I used a two-step build process to prevent unnecessary libraries from being included in the final runtime image. However, this approach meant that configuration changes could only be made during the build phase, requiring a rebuild for any modifications. To improve flexibility, I suggest allowing users to update the configuration through environment variables, instead of needing to rebuild everything locally.
In this pull request, I've incorporated Supervisor to oversee both the bootstrap.sh script and the tomcat server. Here's how it works:
If we set the Docker command to CMD ['bootstrap.sh'], Docker executes the script as its first process (PID 1). When the script completes, the container stops running.
We want the tomcat server to start only after bootstrap.sh has finished executing.
As mentioned in issue #34, it's better for security reasons to run the container as a non-root user.
Supervisor solves these problems by ensuring a sequential execution: it starts the tomcat server only after bootstrap.sh has completed, and it runs the server under a non-root user account(oba_user).
now, you can start the server by environment variables, instead of build args:
oba_app:
container_name: oba_app
depends_on:
- oba_database
build:
context: ./oba
environment:
- JDBC_URL=jdbc:mysql://oba_database:3306/oba_database
- JDBC_USER=oba_user
- JDBC_PASSWORD=oba_password
- TEST_API_KEY=test # For test only, remove in production
- 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
- GOOGLE_MAPS_API_KEY=<YOUR_KEY_HERE>
- GOOGLE_MAPS_CLIENT_ID=<YOUR_CHANNEL_ID_HERE>
- GOOGLE_MAPS_CHANNEL_ID=<YOUR_CLIENT_ID_HERE>
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
For users who want to configure their data-source file manually, just set environment USER_CONFIGURED=1
Before, I used a two-step build process to prevent unnecessary libraries from being included in the final runtime image. However, this approach meant that configuration changes could only be made during the build phase, requiring a rebuild for any modifications. To improve flexibility, I suggest allowing users to update the configuration through environment variables, instead of needing to rebuild everything locally.
In this pull request, I've incorporated Supervisor to oversee both the bootstrap.sh script and the tomcat server. Here's how it works:
CMD ['bootstrap.sh']
, Docker executes the script as its first process (PID 1). When the script completes, the container stops running.tomcat
server to start only afterbootstrap.sh
has finished executing. As mentioned in issue #34, it's better for security reasons to run the container as a non-root user.tomcat
server only afterbootstrap.sh
has completed, and it runs the server under a non-root user account(oba_user
).now, you can start the server by environment variables, instead of build args:
For users who want to configure their data-source file manually, just set environment
USER_CONFIGURED=1