Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new Tomcat version #8

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e8abbde
Update Dockerfile
scrudden Apr 18, 2016
db6ef1f
Setting up to run for Irish Rail instance
scrudden Apr 28, 2016
35f4eb2
Setting up for IR to try and make general
scrudden May 8, 2016
49df827
Merged with myfork
scrudden May 8, 2016
4aea7d6
Adding check to set if postgres db is running.
scrudden May 11, 2016
392cac0
Added AgencyID as env variable and can now change config files using …
scrudden May 11, 2016
2380431
Update README.md
scrudden May 12, 2016
c543d7a
Update README.md
scrudden May 12, 2016
c7e1e43
Update README.md
scrudden May 12, 2016
57a5098
Update README.md
scrudden May 12, 2016
4d9f549
Update README.md
scrudden May 12, 2016
a3e2536
Update README.md
scrudden May 12, 2016
d5bf73e
Now close to starting transiTime for CapMetro example
scrudden May 18, 2016
cc651d7
Merge branch 'master' of https://github.com/scrudden/transitime-docker
scrudden May 18, 2016
484075a
Now need to get API key picked up automatically in JSP
scrudden May 29, 2016
6a26043
Update generate_sql.sh
scrudden May 30, 2016
2e58d76
Went back to how walkeriniraq installed tomcat
scrudden Jun 3, 2016
400c8e7
script to get api key from database
scrudden Jun 3, 2016
ba37729
Merge branch 'master' of https://github.com/scrudden/transitime-docker
scrudden Jun 3, 2016
150760a
host should be the host where the RMI server is running not the datab…
scrudden Jun 9, 2016
261650c
Update README.md
scrudden Jun 10, 2016
c5f4fde
Update README.md
scrudden Jun 10, 2016
9787dfd
removed long and lat setting from config as defaults to north america
scrudden Jun 11, 2016
4fb2c95
Update README.md
scrudden Jun 11, 2016
996cd24
Update README.md
scrudden Jun 11, 2016
089a18a
Changed prediction generator to historical average using caching
scrudden Jun 13, 2016
06ee641
Merge branch 'master' of https://github.com/scrudden/transitime-docker
scrudden Jun 13, 2016
4688916
Update transiTimeConfig.xml
scrudden Jun 13, 2016
7b472e6
Update tomcat version.
scrudden Jul 11, 2016
2c77ec4
Update transiTimeConfig.xml
scrudden Aug 4, 2016
5a51d34
Update transiTimeConfig.xml
scrudden Aug 4, 2016
39b79d1
Update Dockerfile
scrudden Aug 13, 2016
249f289
Added new tomcat version and pgp key ( which is unavaialable on keyse…
invalid-email-address Sep 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 76 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
FROM maven:3.3
FROM maven:3.3-jdk-8
MAINTAINER Nathan Walker <[email protected]>

ENV TRANSITIMECORE /transitime-core
ENV PGPASSWORD=transitime
ENV AGENCYNAME=CAPMETRO
ENV AGENCYID=1
ENV GTFS_URL="https://data.texas.gov/download/r4v4-vz24/application/zip"
ENV GTFSRTVEHICLEPOSITIONS="https://data.texas.gov/download/eiei-9rpf/application/octet-stream"

RUN apt-get update \
&& apt-get install -y postgresql-client \
&& apt-get install -y git-core
&& apt-get install -y git-core \
&& apt-get install -y vim

ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $CATALINA_HOME/bin:$PATH
Expand All @@ -23,10 +31,11 @@ RUN gpg --keyserver pool.sks-keyservers.net --recv-keys \
A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 \
DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 \
F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE \
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23
F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23 \
4b28deddee6372106aac7ead6af524c7c9614644

ENV TOMCAT_MAJOR 8
ENV TOMCAT_VERSION 8.0.26
ENV TOMCAT_VERSION 8.0.46
ENV TOMCAT_TGZ_URL https://www.apache.org/dist/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz

RUN set -x \
Expand All @@ -39,29 +48,75 @@ RUN set -x \

EXPOSE 8080


# Install json parser so we can read API key for CreateAPIKey output

RUN wget http://stedolan.github.io/jq/download/linux64/jq

RUN chmod +x ./jq

RUN cp jq /usr/bin/

RUN git clone https://github.com/scrudden/core.git /transitime-core

#RUN git clone https://github.com/Transitime/core.git /transitime-core

WORKDIR /transitime-core

#RUN git checkout kalman_predictions
RUN git checkout historical_predictions

#RUN git checkout shade_build_upstream

RUN mvn install -DskipTests

WORKDIR /
RUN mkdir /usr/local/transitime
RUN mkdir /usr/local/transitime/db
RUN mkdir /usr/local/transitime/config
RUN mkdir /usr/local/transitime/logs
RUN mkdir /usr/local/transitime/cache

RUN \
git clone https://github.com/walkeriniraq/transittime-core.git && \
cd transittime-core && \
git checkout cap-metro && \
mvn install -DskipTests && \
cd / && \
mkdir /usr/local/transitime && \
mkdir /usr/local/transitime/db && \
mv /transittime-core/transitime/target/transitime.jar /usr/local/transitime && \
mv /transittime-core/transitimeApi/target/api.war /usr/local/tomcat/webapps && \
mv /transittime-core/transitime/target/classes/ddl_postgres*.sql /usr/local/transitime/db && \
rm -rf /transitime-core && \
rm -rf ~/.m2/repository

# Deploy core. The work horse of transiTime.
RUN cp /transitime-core/transitime/target/*.jar /usr/local/transitime/

# Deploy API which talks to core using RMI calls.
RUN cp /transitime-core/transitimeApi/target/api.war /usr/local/tomcat/webapps

# Deploy webapp which is a UI based on the API.
RUN cp /transitime-core/transitimeWebapp/target/web.war /usr/local/tomcat/webapps

RUN cp /transitime-core/transitime/target/classes/ddl_postgres*.sql /usr/local/transitime/db

# RUN rm -rf /transitime-core
# RUN rm -rf ~/.m2/repository

# Scripts required to start transiTime. These are in the order they need to be run.
ADD bin/check_db_up.sh check_db_up.sh
ADD bin/generate_sql.sh generate_sql.sh
ADD bin/create_tables.sh create_tables.sh
ADD bin/create_api_key.sh create_api_key.sh
ADD bin/import_cap_metro.sh import_cap_metro.sh
ADD bin/connect_to_db.sh connect_to_db.sh
ADD bin/create_webagency.sh create_webagency.sh
ADD bin/import_gtfs.sh import_gtfs.sh
ADD bin/start_transitime.sh start_transitime.sh
ADD config/postgres_hibernate.cfg.xml /usr/local/transitime/hibernate.cfg.xml
ADD config/transitime.properties /usr/local/transitime/transitime.properties
ADD bin/get_api_key.sh get_api_key.sh

# Handy utility to allow you connect directly to database
ADD bin/connect_to_db.sh connect_to_db.sh

# RUN ./generate_sql.sh

RUN \
sed -i 's/\r//' *.sh &&\
chmod 777 *.sh

ADD config/postgres_hibernate.cfg.xml /usr/local/transitime/config/hibernate.cfg.xml
ADD config/transitime.properties /usr/local/transitime/config/transitime.properties
ADD config/transitime.properties /usr/local/transitimeTomcatConfig/transitime.properties
ADD config/transiTimeConfig.xml /usr/local/transitime/config/transiTimeConfig.xml

EXPOSE 8080

CMD ["/start_transitime.sh"]

31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# transitime-db

http://transitime-host.cloudapp.net/api/v1/key/f18a8240/agency/cap-metro/command/predictions?rs=803%7C4830
# transitime-docker

Things to make transitime go:

- Ubuntu
- sudo apt-get install git
- git clone https://github.com/walkeriniraq/transitime-db.git
- git clone https://github.com/scrudden/transitime-docker.git
- curl -sSL https://get.docker.com/ | sh (i.e. install docker)
- Configure agency details in the go.sh script. Here you set the agency name, agency id** (as in GTFS feed), GTFS feed location and GTFS-realtime vehicle location url.
- ./go.sh
-
**AgencyId is optional in GTFS so just set to 1 if none specified.

The go script will build the transitime container (takes a long time), start the postgres db, create the tables,
push the cap metro data into the db, create a default API key (f18a8240) and then start the server, connecting
it to the server's port 80.
push the gtfs data into the db, create an API key and then start the api service and web user interface service.

To view web interface
```
http://[ipaddress]:8080/web
```
To view api
```
http://[ipaddress]:8080/api
```

You can get the ip address by running
```
docker-machine ip [machine name]

docker-machine ip default
```


If you want to run an instance of the transitime app, you can call:
./run_to_bash.sh

19 changes: 19 additions & 0 deletions bin/check_db_up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
export PGPASSWORD=transitime

echo 'Checking database is running.'
RET=1
SUCCESS=0
until [ "$RET" -eq "$SUCCESS" ]; do

psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -c "SELECT EXTRACT(DAY FROM TIMESTAMP '2001-02-16 20:38:40');"
RET="$?"

if [ "$RET" -ne "$SUCCESS" ]
then
echo 'Database is not running.'
sleep 10
fi
done

echo 'Database is now running.'
3 changes: 1 addition & 2 deletions bin/connect_to_db.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/usr/bin/env bash
export PGPASSWORD=transitime
psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_POST_5432_TCP_PORT" -U postgres -d cap-metro
psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_POST_5432_TCP_PORT" -U postgres -d $AGENCYNAME
28 changes: 10 additions & 18 deletions bin/create_api_key.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
#!/usr/bin/env bash
export PGPASSWORD=transitime
java \
-Dtransitime.db.dbName=cap-metro \
-Dtransitime.db.dbType=postgresql \
-Dtransitime.db.dbUserName=postgres \
-Dtransitime.db.dbPassword=$PGPASSWORD \
-Dtransitime.core.agencyId=cap-metro \
-Dtransitime.hibernate.configFile=/usr/local/transitime/hibernate.cfg.xml \
-Dhibernate.connection.url=jdbc:postgresql://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/cap-metro \
-Dhibernate.connection.username=postgres \
-Dhibernate.connection.password=$PGPASSWORD \
-cp /usr/local/transitime/transitime.jar \
org.transitime.applications.CreateAPIKey \
-d "foo" \
-e "[email protected]" \
-n "Nathan Walker" \
-p "123" \
-u "http://foo.bar.com"

# This is to substitute into config file the env values
sed -i s#"POSTGRES_PORT_5432_TCP_ADDR"#"$POSTGRES_PORT_5432_TCP_ADDR"#g /usr/local/transitime/config/*
sed -i s#"POSTGRES_PORT_5432_TCP_PORT"#"$POSTGRES_PORT_5432_TCP_PORT"#g /usr/local/transitime/config/*
sed -i s#"PGPASSWORD"#"$PGPASSWORD"#g /usr/local/transitime/config/*
sed -i s#"AGENCYNAME"#"$AGENCYNAME"#g /usr/local/transitime/config/*
sed -i s#"GTFSRTVEHICLEPOSITIONS"#"$GTFSRTVEHICLEPOSITIONS"#g /usr/local/transitime/config/*

cp /usr/local/transitime/config/transitime.properties /usr/local/transitimeTomcatConfig/transitime.properties

java -jar /usr/local/transitime/CreateAPIKey.jar -c "/usr/local/transitime/config/transiTimeConfig.xml" -d "foo" -e "[email protected]" -n "Sean Og Crudden" -p "123456" -u "http://www.transitime.org"
7 changes: 3 additions & 4 deletions bin/create_tables.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env bash
export PGPASSWORD=transitime
createdb -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres cap-metro
createdb -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres $AGENCYNAME
psql \
-h "$POSTGRES_PORT_5432_TCP_ADDR" \
-p "$POSTGRES_PORT_5432_TCP_PORT" \
-U postgres \
-d cap-metro \
-d $AGENCYNAME \
-f /usr/local/transitime/db/ddl_postgres_org_transitime_db_structs.sql
psql \
-h "$POSTGRES_PORT_5432_TCP_ADDR" \
-p "$POSTGRES_PORT_5432_TCP_PORT" \
-U postgres \
-d cap-metro \
-d $AGENCYNAME \
-f /usr/local/transitime/db/ddl_postgres_org_transitime_db_webstructs.sql
12 changes: 12 additions & 0 deletions bin/create_webagency.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# This is to substitute into config file the env values
sed -i s#"POSTGRES_PORT_5432_TCP_ADDR"#"$POSTGRES_PORT_5432_TCP_ADDR"#g /usr/local/transitime/config/*
sed -i s#"POSTGRES_PORT_5432_TCP_PORT"#"$POSTGRES_PORT_5432_TCP_PORT"#g /usr/local/transitime/config/*
sed -i s#"PGPASSWORD"#"$PGPASSWORD"#g /usr/local/transitime/config/*
sed -i s#"AGENCYNAME"#"$AGENCYNAME"#g /usr/local/transitime/config/*
sed -i s#"GTFSRTVEHICLEPOSITIONS"#"$GTFSRTVEHICLEPOSITIONS"#g /usr/local/transitime/config/*

cp /usr/local/transitime/config/transitime.properties /usr/local/transitimeTomcatConfig/transitime.properties

java -Dtransitime.db.dbName=$AGENCYNAME -Dtransitime.hibernate.configFile=/usr/local/transitime/config/hibernate.cfg.xml -Dtransitime.db.dbHost=$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT -Dtransitime.db.dbUserName=postgres -Dtransitime.db.dbPassword=$PGPASSWORD -Dtransitime.db.dbType=postgresql -cp transitime-core/transitime/target/CreateAPIKey.jar org.transitime.db.webstructs.WebAgency $AGENCYID 127.0.0.1 $AGENCYNAME postgresql $POSTGRES_PORT_5432_TCP_ADDR postgres $PGPASSWORD
6 changes: 6 additions & 0 deletions bin/generate_sql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
java -jar $TRANSITIMECORE/transitime/target/SchemaGenerator.jar -p org.transitime.db.structs -o /usr/local/transitime/db/
java -jar $TRANSITIMECORE/transitime/target/SchemaGenerator.jar -p org.transitime.db.webstructs -o /usr/local/transitime/db/



1 change: 1 addition & 0 deletions bin/get_api_key.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres -d $AGENCYNAME -t -c "SELECT applicationkey from apikeys;"|xargs
23 changes: 0 additions & 23 deletions bin/import_cap_metro.sh

This file was deleted.

20 changes: 20 additions & 0 deletions bin/import_gtfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# This is to substitute into config file the env values.
sed -i s#"POSTGRES_PORT_5432_TCP_ADDR"#"$POSTGRES_PORT_5432_TCP_ADDR"#g /usr/local/transitime/config/*
sed -i s#"POSTGRES_PORT_5432_TCP_PORT"#"$POSTGRES_PORT_5432_TCP_PORT"#g /usr/local/transitime/config/*
sed -i s#"PGPASSWORD"#"$PGPASSWORD"#g /usr/local/transitime/config/*
sed -i s#"AGENCYNAME"#"$AGENCYNAME"#g /usr/local/transitime/config/*
sed -i s#"GTFSRTVEHICLEPOSITIONS"#"$GTFSRTVEHICLEPOSITIONS"#g /usr/local/transitime/config/*

cp /usr/local/transitime/config/transitime.properties /usr/local/transitimeTomcatConfig/transitime.properties

java -Xmx1000M -Dtransitime.core.agencyId=$AGENCYID -Dtransitime.configFiles=/usr/local/transitime/config/transiTimeConfig.xml -Dtransitime.logging.dir=/usr/local/transitime/logs/ -Dlogback.configurationFile=$TRANSITIMECORE/transitime/src/main/resouces/logbackGtfs.xml -jar $TRANSITIMECORE/transitime/target/GtfsFileProcessor.jar -gtfsUrl $GTFS_URL -maxTravelTimeSegmentLength 400

psql \
-h "$POSTGRES_PORT_5432_TCP_ADDR" \
-p "$POSTGRES_PORT_5432_TCP_PORT" \
-U postgres \
-d $AGENCYNAME \
-c "update activerevisions set configrev=0 where configrev = -1; update activerevisions set traveltimesrev=0 where traveltimesrev = -1;"

36 changes: 24 additions & 12 deletions bin/start_transitime.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
#!/usr/bin/env bash
export PGPASSWORD=transitime
echo "hibernate.connection.url=jdbc:postgresql://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/cap-metro" >> /usr/local/transitime/transitime.properties

# This is to substitute into config file the env values
sed -i s#"POSTGRES_PORT_5432_TCP_ADDR"#"$POSTGRES_PORT_5432_TCP_ADDR"#g /usr/local/transitime/config/*
sed -i s#"POSTGRES_PORT_5432_TCP_PORT"#"$POSTGRES_PORT_5432_TCP_PORT"#g /usr/local/transitime/config/*
sed -i s#"PGPASSWORD"#"$PGPASSWORD"#g /usr/local/transitime/config/*
sed -i s#"AGENCYNAME"#"$AGENCYNAME"#g /usr/local/transitime/config/*
sed -i s#"GTFSRTVEHICLEPOSITIONS"#"$GTFSRTVEHICLEPOSITIONS"#g /usr/local/transitime/config/*

cp /usr/local/transitime/config/transitime.properties /usr/local/transitimeTomcatConfig/transitime.properties

rmiregistry &

#set the API as an environment variable so we can set in JSP of template/includes.jsp in the transitime webapp
export APIKEY=$(/get_api_key.sh)

# make it so we can also access as a system property in the JSP
export JAVA_OPTS="$JAVA_OPTS -Dtransitime.apikey=$(/get_api_key.sh)"

echo JAVA_OPTS $JAVA_OPTS

/usr/local/tomcat/bin/startup.sh
java \
-Dtransitime.hibernate.configFile=/usr/local/transitime/hibernate.cfg.xml \
-Dhibernate.connection.url=jdbc:postgresql://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/cap-metro \
-Dhibernate.connection.username=postgres \
-Dhibernate.connection.password=$PGPASSWORD \
-Dtransitime.avl.gtfsRealtimeFeedURI="https://data.texas.gov/download/i5qp-g5fd/application/octet-stream" \
-Dtransitime.modules.optionalModulesList=org.transitime.avl.GtfsRealtimeModule \
-Dtransitime.core.agencyId=cap-metro \
-cp /usr/local/transitime/transitime.jar \
org.transitime.applications.Core

java -Dtransitime.configFiles=/usr/local/transitime/config/transiTimeConfig.xml -Dtransitime.core.agencyId=$AGENCYID -Dtransitime.logging.dir=/usr/local/transitime/logs/ -jar $TRANSITIMECORE/transitime/target/Core.jar -configRev 0 /dev/null 2>&1



Loading