Skip to content

Commit

Permalink
Improvements for running MOTIS in Docker (#154)
Browse files Browse the repository at this point in the history
* store schedule.raw in data dir

* update docker file

* introduce system config (conf update)

* dockerfile: add system config

* ci: ui/web: strip elm-stuff and src dir

* input volume

* intermodal router tripbased
  • Loading branch information
felixguendling authored Sep 9, 2021
1 parent 519abbc commit 67aea27
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ jobs:

- name: Compile Web Interface
if: matrix.config.webui == 'On'
run: cmake --build build --target motis-web-ui
run: |
cmake --build build --target motis-web-ui
rm -r ui/web/elm-stuff
rm -r ui/web/src
- name: Create Distribution
if: matrix.config.artifact
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ jobs:
# ==== DISTRIBUTION ====
- name: Compile Web Interface
if: matrix.config.webui == 'On'
run: cmake --build build --target motis-web-ui
run: |
cmake --build build --target motis-web-ui
rm -r ui/web/elm-stuff
rm -r ui/web/src
- name: Move Profiles
if: matrix.config.mode == 'Release'
Expand Down
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[conf]
url=git@github.com:motis-project/conf.git
branch=master
commit=b7d42aa063dd815cee6157bd27dce0caa82d2fa6
commit=4c809244b10de534f4423ce4b27aa1a371610e96
[ctx]
url=git@github.com:motis-project/ctx.git
branch=master
Expand Down
28 changes: 26 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
FROM alpine:3.14
ARG TARGETARCH
ADD motis-linux-$TARGETARCH/motis-linux-$TARGETARCH.tar.bz2 /
RUN addgroup -S motis && adduser -S motis -G motis
RUN addgroup -S motis && adduser -S motis -G motis && \
mkdir /data && \
chown motis:motis /data && \
echo -e "\
server.static_path=/motis/web \
\
intermodal.router=tripbased \
\
[import] \
paths=schedule:/input/schedule \
paths=osm:/input/osm.pbf \
data_dir=/data \
\
[tiles] \
profile=/motis/tiles-profiles/background.lua \
\
[osrm] \
profiles=/motis/osrm-profiles/car.lua \
profiles=/motis/osrm-profiles/bike.lua \
profiles=/motis/osrm-profiles/bus.lua \
\
[ppr] \
profile=/motis/ppr-profiles/default.json \
" > /system_config.ini
EXPOSE 8080
VOLUME ["/data"]
VOLUME ["/input"]
WORKDIR /motis
USER motis
CMD ["/motis/motis", "-c", "/data/config.ini"]
CMD ["/motis/motis", "--system_config", "/system_config.ini", "-c", "/input/config.ini"]
1 change: 1 addition & 0 deletions base/loader/include/motis/loader/loader_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace motis::loader {
struct loader_options {
std::pair<std::time_t, std::time_t> interval() const;
std::string graph_path(std::string const& data_dir) const;
std::string fbs_schedule_path(std::string const& data_dir, size_t id) const;

std::vector<std::string> dataset_{"rohdaten"};
std::string schedule_begin_{"TODAY"};
Expand Down
2 changes: 0 additions & 2 deletions base/loader/include/motis/loader/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ namespace flatbuffers64 {
class FlatBufferBuilder; // NOLINT(readability-identifier-naming)
} // namespace flatbuffers64

constexpr auto const SCHEDULE_FILE = "schedule.raw";

namespace motis::loader {

struct format_parser {
Expand Down
13 changes: 8 additions & 5 deletions base/loader/src/loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ schedule_ptr load_schedule(loader_options const& opt,
std::vector<dataset_mem_t> mem;
mem.reserve(opt.dataset_.size());
for (auto const& [i, path] : utl::enumerate(opt.dataset_)) {
auto const binary_schedule_file = fs::path(path) / SCHEDULE_FILE;
auto const binary_schedule_file = opt.fbs_schedule_path(data_dir, i);
if (fs::is_regular_file(binary_schedule_file)) {
mem.emplace_back(
cista::mmap{binary_schedule_file.generic_string().c_str(),
cista::mmap::protection::READ});
mem.emplace_back(cista::mmap{binary_schedule_file.c_str(),
cista::mmap::protection::READ});
continue;
}

Expand Down Expand Up @@ -127,7 +126,11 @@ schedule_ptr load_schedule(loader_options const& opt,
}

if (opt.write_serialized_) {
utl::file(binary_schedule_file.string().c_str(), "w+")
auto const schedule_dir = fs::path{binary_schedule_file}.parent_path();
if (!schedule_dir.empty()) {
fs::create_directories(schedule_dir);
}
utl::file(binary_schedule_file.c_str(), "w+")
.write(builder.GetBufferPointer(), builder.GetSize());
}

Expand Down
11 changes: 11 additions & 0 deletions base/loader/src/loader_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,15 @@ std::string loader_options::graph_path(std::string const& data_dir) const {
}
}

std::string loader_options::fbs_schedule_path(std::string const& data_dir,
size_t const id) const {
if (dataset_prefix_.empty()) {
return (fs::path{data_dir} / "schedule" / "schedule.raw").generic_string();
} else {
return (fs::path{data_dir} / "schedule" /
(dataset_prefix_.at(id) + "_schedule.raw"))
.generic_string();
}
}

} // namespace motis::loader

0 comments on commit 67aea27

Please # to comment.