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

add docker support #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ghcr.io/motis-project/motis:latest

USER root
RUN mkdir -p /input/schedule && chown -R motis /input /system_config.ini
RUN apk add go python3 py3-pip

USER motis

RUN pip install requests
RUN go install github.com/patrickbr/gtfstidy@latest

# demo data for Aachen
RUN wget https://github.com/motis-project/test-data/raw/aachen/aachen.osm.pbf -O /input/osm.pbf

ADD --chown=motis src/ /tools/src
ADD --chown=motis feeds/ /tools/feeds
ADD --chown=motis transitland-atlas/ /tools/transitland-atlas
ADD config.ini /system_config.ini
ADD src/transitous /usr/local/bin/

RUN transitous fetch aachen.json
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ routing service that:
* does not stop at borders
* aims at crowd-sourced maintenance of data feeds in the spirit of FOSS

## Docker development install
```
git submodule update
docker-compose up -d
```
### Import new feed
```
docker-compose run --rm motis transitous fetch <feed-file-name>
```


Note than docker volume "input" is filled within the first start. If you make changes you have to delete the volume.

**Attention: Data lost!**
```
docker-compose down -v
docker-compose up -d --build
```



## Contact

* Matrix channel: [#opentransport:matrix.org](https://matrix.to/#/#opentransport:matrix.org) (for now)
Expand Down
37 changes: 37 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2024 Jonah Brüchert <[email protected]>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

modules=intermodal
modules=address
modules=tiles
modules=osrm
modules=ppr
modules=parking
modules=nigiri
modules=target

intermodal.router=nigiri
dataset.no_schedule=true

[server]
static_path=/motis/web

#[import]
#paths=osm:/input/osm.pbf
#paths=schedule-aachen-aachen:/input/schedule/aachen_aachen.gtfs.zip
#data_dir=/data

[nigiri]
first_day=TODAY
num_days=365

[osrm]
profiles=/motis/osrm-profiles/car.lua
profiles=/motis/osrm-profiles/bike.lua

[ppr]
profile=/motis/ppr-profiles/default.json

[tiles]
profile=/motis/tiles-profiles/background.lua
26 changes: 26 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "3.7"

services:
motis:
build: .
# image: ghcr.io/motis-project/motis:latest
volumes:
- input:/input
- data:/data
- web:/motis/web
ports:
- 8080:8080

# web:
# image: nginx
# volumes:
# - web:/usr/share/nginx/html:ro
# ports:
# - 80:80
# depends_on:
# - motis

volumes:
input:
data:
web:
15 changes: 15 additions & 0 deletions feeds/aachen.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"maintainers": [
{
"name": "ex",
"github": "exmatrikulator"
}
],
"sources": [
{
"name": "aachen",
"type": "http",
"url": "http://opendata.avv.de/archive_GTFS/2024/2024-01/AVV_GTFS_Masten_mit_SPNV_20240113.zip"
}
]
}
14 changes: 14 additions & 0 deletions src/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,20 @@ def postprocess(self, source: Source, path: Path):
subprocess.call(command, cwd=tmpdir)

shutil.rmtree(tmpdir)

if os.path.exists("/input/schedule/"):
shutil.copy(output_file_path, "/input/schedule/")

# TODO: write a motis ini class
if not os.path.exists("/input/config.ini"):
with open('/input/config.ini', 'a') as config_ini:
config_ini.write("[import]\n")
config_ini.write("data_dir=/data\n")
config_ini.write("paths=osm:/input/osm.pbf\n")


with open('/input/config.ini', 'a') as config_ini:
config_ini.write(f"paths=schedule-{path.name.split('.')[0].replace('_','-')}:/input/schedule/{path.name}\n")

def fetch(self, metadata: Path):
region = Region(json.load(open(metadata, "r")))
Expand Down
19 changes: 19 additions & 0 deletions src/transitous
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

fetch() {
cd /tools
PATH=$PATH:$HOME/go/bin
python src/fetch.py feeds/$1
}


case $1 in
"fetch" )
fetch $2
;;
*)
echo >&2 "use 'fetch <filename>'"
exit 1
;;
esac