Skip to content

Commit

Permalink
Merge pull request #9 from etalab/add-gtfs2netexfr
Browse files Browse the repository at this point in the history
Ajout du convertisseur GTFS vers NeTEx (beta)
  • Loading branch information
thbar authored Jan 12, 2022
2 parents 295cc71 + 9dfc0d9 commit ec0ff8c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,49 @@ WORKDIR /transport-validator
RUN cargo build --release
RUN strip ./target/release/main

# https://github.com/CanalTP/transit_model/tree/master/gtfs2netexfr (rust app)
# We need `proj` to be installed for the `proj_sys` crate to compile. The various options considered were:
# - `apt-get install proj-bin` (compilation fails with error `pkg-config` won't find `proj.pc`)
# - `apt-get install libproj-dev` (compilation fails because this install proj 7 and we need proj >= 8)
# - `make install_proj[_deps]` (https://github.com/CanalTP/transit_model/blob/master/Makefile) ; it works if we
# add `apt-get install sudo` which is missing, but takes a very long time at the moment
# - relying on https://hub.docker.com/r/kisiodigital/rust-ci, which provides a `proj` flavour (see
# https://github.com/CanalTP/ci-images/blob/master/rust/proj/Dockerfile)
#
# We could also probably "just" grab the `proj-ci` artefacts with a bit more time here:
# - https://hub.docker.com/r/kisiodigital/proj-ci
# - https://github.com/CanalTP/ci-images
#
FROM kisiodigital/rust-ci:latest-proj8.1.0 as builder_proj
WORKDIR /
RUN git clone --depth=1 --branch=master --single-branch https://github.com/CanalTP/transit_model
WORKDIR /transit_model
# NOTE: when using the kisio rust-ci as a base image, CARGO_TARGET_DIR is set to something like `/tmp/cargo-release`.
# To avoid breaking the build in case of variable change upstream, we instead force the build to be local, which
# makes the COPY step in the next stage more reliable too. Useful debugging tips including `RUN env`, and adding `--verbose`
RUN CARGO_TARGET_DIR=./target cargo build --manifest-path=gtfs2netexfr/Cargo.toml --release
RUN strip ./target/release/gtfs2netexfr

FROM ubuntu:focal
COPY --from=builder /gtfs-to-geojson/target/release/gtfs-geojson /usr/local/bin/gtfs-geojson
COPY --from=builder /transport-validator/target/release/main /usr/local/bin/transport-validator
COPY --from=builder_proj /transit_model/target/release/gtfs2netexfr /usr/local/bin/gtfs2netexfr
RUN apt-get -y update && apt-get -y install libssl-dev
RUN apt-get -y install default-jre
RUN apt-get -y install curl
# https://github.com/MobilityData/gtfs-validator (java app)
RUN curl --location -O https://github.com/MobilityData/gtfs-validator/releases/download/v2.0.0/gtfs-validator-v2.0.0_cli.jar
# https://github.com/CUTR-at-USF/gtfs-realtime-validator/blob/master/gtfs-realtime-validator-lib/README.md#batch-processing (java app)
RUN curl --location -O https://s3.amazonaws.com/gtfs-rt-validator/travis_builds/gtfs-realtime-validator-lib/1.0.0-SNAPSHOT/gtfs-realtime-validator-lib-1.0.0-SNAPSHOT.jar

# for gtfs2netexfr
RUN apt-get -y install libtiff5 libcurl3-nss
# hackish ; TODO: check out https://github.com/CanalTP/ci-images instead
COPY --from=builder_proj /usr/lib/libproj.* /usr/lib

# run each binary (as part of CI) to make sure they do not lack a dynamic dependency
RUN /usr/local/bin/gtfs-geojson --help
RUN /usr/local/bin/transport-validator --help
RUN /usr/local/bin/gtfs2netexfr --help

# TODO: test java binaries (they do not have a `--help` currently I believe)
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This repository contains a Docker setup to consolidate various converters and validators that we use or will use soon on [transport.data.gouv.fr](https://transport.data.gouv.fr):
* https://github.com/rust-transit/gtfs-to-geojson.git
* https://github.com/etalab/transport-validator.git
* https://github.com/CanalTP/transit_model/tree/master/gtfs2netexfr
* https://github.com/MobilityData/gtfs-validator
* https://github.com/CUTR-at-USF/gtfs-realtime-validator/blob/master/gtfs-realtime-validator-lib/README.md#batch-processing

Expand Down Expand Up @@ -42,6 +43,13 @@ docker run -a stdout -t localtest /usr/local/bin/gtfs-geojson --help
# https://github.com/etalab/transport-validator.git
docker run -a stdout -t localtest /usr/local/bin/transport-validator --help
# https://github.com/CanalTP/transit_model/tree/master/gtfs2netexfr
docker run -a stdout -t localtest /usr/local/bin/gtfs2netexfr --help
# actual run, using a "data" subfolder shared with the docker machine (requires curl 7.73+)
curl --create-dirs --output-dir ./data -O https://data.angers.fr/api/datasets/1.0/angers-loire-metropole-horaires-reseau-irigo-gtfs-rt/alternative_exports/irigo_gtfs_zip
docker run -a stdout -a stderr -v $(pwd)/data:/data -t localtest /usr/local/bin/gtfs2netexfr -i /data/irigo_gtfs_zip -o /data --participant test
# https://github.com/MobilityData/gtfs-validator/tree/v2.0.0-docs
docker run -a stdout -t localtest java -jar gtfs-validator-v2.0.0_cli.jar
Expand Down

0 comments on commit ec0ff8c

Please sign in to comment.