Use Go Modules to manage Go code's dependency (#42)
* chore: init go.mod * chore: ignore go binaries * chore: remove thrift, will be managed by go mod * chore: build c++ and go in one repo * chore: depends on snappy * chore: build snappy_command * chore: compress wayid2nodeids.csv by snappy
This commit is contained in:
parent
a3eb24a0fc
commit
bb147f369b
@ -32,13 +32,4 @@ ENV GO_HOME=/usr/local/go
|
||||
ENV PATH=${GO_HOME}/bin/:$PATH
|
||||
ENV GOPATH=/workspace/go
|
||||
|
||||
# install thrift 0.12.0 go pkg
|
||||
RUN cd /workspace/go && \
|
||||
mkdir -p src/github.com/apache && \
|
||||
cd src/github.com/apache && \
|
||||
git clone -b 0.12.0 https://github.com/apache/thrift.git && \
|
||||
cd thrift && \
|
||||
git branch && \
|
||||
cd /workspace/go && \
|
||||
go install github.com/apache/thrift/lib/go/thrift
|
||||
|
||||
|
||||
@ -1,36 +1,38 @@
|
||||
|
||||
|
||||
FROM wangyoucao577/osrm-backend-dev as builder
|
||||
ARG BRANCH_NAME=master-telenav
|
||||
|
||||
RUN mkdir -p /osrm-build
|
||||
WORKDIR /workspace/
|
||||
|
||||
ARG BRANCH_NAME=master-telenav
|
||||
RUN echo "Building branch ${BRANCH_NAME}" && \
|
||||
git clone -b ${BRANCH_NAME} https://github.com/Telenav/osrm-backend.git && \
|
||||
mkdir -p osrm-backend/build && \
|
||||
git clone -b ${BRANCH_NAME} https://github.com/Telenav/osrm-backend.git
|
||||
|
||||
RUN mkdir -p osrm-backend/build && \
|
||||
cd osrm-backend/build && \
|
||||
cmake .. -DENABLE_LTO=On && \
|
||||
cmake --build . -- -j && \
|
||||
mkdir /osrm-build && \
|
||||
mkdir /osrm-data && \
|
||||
cp /osrm-backend/build/osrm* /osrm-build/ && \
|
||||
cp -r /osrm-backend/profiles /osrm-build/
|
||||
cp /workspace/osrm-backend/build/osrm* /osrm-build/ && \
|
||||
cp -r /workspace/osrm-backend/profiles /osrm-build/
|
||||
|
||||
|
||||
FROM wangyoucao577/osrm-backend-dev as gobuilder
|
||||
ARG BRANCH_NAME=master-telenav
|
||||
|
||||
WORKDIR /workspace/go
|
||||
RUN echo "Building branch ${BRANCH_NAME}" && \
|
||||
mkdir -p src/github.com/Telenav && \
|
||||
cd src/github.com/Telenav && \
|
||||
git clone -b ${BRANCH_NAME} https://github.com/Telenav/osrm-backend.git && \
|
||||
cd ../../../ && \
|
||||
if [ -d "src/github.com/Telenav/osrm-backend/traffic_updater/go/osrm_traffic_updater" ]; then \
|
||||
go get github.com/qedus/osmpbf && \
|
||||
go install github.com/Telenav/osrm-backend/traffic_updater/go/gen-go/proxy && \
|
||||
go install github.com/Telenav/osrm-backend/traffic_updater/go/osrm_traffic_updater && \
|
||||
go install github.com/Telenav/osrm-backend/traffic_updater/go/wayid2nodeid_extractor && \
|
||||
ls -lh bin/ \
|
||||
;fi
|
||||
RUN cd /workspace/osrm-backend && \
|
||||
if [ -d "traffic_updater/go/osrm_traffic_updater" ]; then \
|
||||
cd traffic_updater/go/osrm_traffic_updater && \
|
||||
go install && \
|
||||
cd ../../../ \
|
||||
;fi && \
|
||||
if [ -d "traffic_updater/go/wayid2nodeid_extractor" ]; then \
|
||||
cd traffic_updater/go/wayid2nodeid_extractor && \
|
||||
go install && \
|
||||
cd ../../../ \
|
||||
;fi && \
|
||||
if [ -d "traffic_updater/go/snappy_command" ]; then \
|
||||
cd traffic_updater/go/snappy_command && \
|
||||
go install && \
|
||||
cd ../../../ \
|
||||
;fi && \
|
||||
ls -lh /workspace/go/bin
|
||||
|
||||
|
||||
FROM debian:stretch-slim as runstage
|
||||
@ -44,7 +46,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
|
||||
RUN mkdir -p /osrm-build /osrm-data /osrm-logs
|
||||
|
||||
COPY --from=builder /osrm-build /osrm-build/
|
||||
COPY --from=gobuilder /workspace/go/bin /osrm-build/
|
||||
COPY --from=builder /workspace/go/bin /osrm-build/
|
||||
COPY ./docker-entrypoint.sh /
|
||||
RUN chmod +x /docker-entrypoint.sh
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ OSRM_EXTRA_COMMAND="-l DEBUG"
|
||||
OSRM_ROUTED_STARTUP_COMMAND=" -a MLD --max-table-size 8000 "
|
||||
MAPDATA_NAME_WITH_SUFFIX=map
|
||||
WAYID2NODEIDS_MAPPING_FILE=wayid2nodeids.csv
|
||||
WAYID2NODEIDS_MAPPING_FILE_COMPRESSED=${WAYID2NODEIDS_MAPPING_FILE}.snappy
|
||||
|
||||
_sig() {
|
||||
kill -TERM $child 2>/dev/null
|
||||
@ -17,7 +18,7 @@ if [ "$1" = 'routed_startup' ]; then
|
||||
TRAFFIC_PROXY_IP=${2:-"10.189.102.81"}
|
||||
|
||||
cd ${DATA_PATH}
|
||||
${BUILD_PATH}/osrm_traffic_updater -c ${TRAFFIC_PROXY_IP} -d=false -m ${WAYID2NODEIDS_MAPPING_FILE} -f ${TRAFFIC_FILE}
|
||||
${BUILD_PATH}/osrm_traffic_updater -c ${TRAFFIC_PROXY_IP} -d=false -m ${WAYID2NODEIDS_MAPPING_FILE_COMPRESSED} -f ${TRAFFIC_FILE}
|
||||
ls -lh
|
||||
${BUILD_PATH}/osrm-customize ${MAPDATA_NAME_WITH_SUFFIX}.osrm --segment-speed-file ${TRAFFIC_FILE} ${OSRM_EXTRA_COMMAND}
|
||||
${BUILD_PATH}/osrm-routed ${MAPDATA_NAME_WITH_SUFFIX}.osrm ${OSRM_ROUTED_STARTUP_COMMAND} &
|
||||
@ -52,11 +53,13 @@ elif [ "$1" = 'compile_mapdata' ]; then
|
||||
${BUILD_PATH}/osrm-partition $DATA_PATH/${MAPDATA_NAME_WITH_SUFFIX}.osrm ${OSRM_EXTRA_COMMAND}
|
||||
${BUILD_PATH}/osrm-customize $DATA_PATH/${MAPDATA_NAME_WITH_SUFFIX}.osrm ${OSRM_EXTRA_COMMAND}
|
||||
${BUILD_PATH}/wayid2nodeid_extractor -i $DATA_PATH/${MAPDATA_NAME_WITH_SUFFIX}.osm.pbf -o $DATA_PATH/${WAYID2NODEIDS_MAPPING_FILE} -b=${IS_TELENAV_PBF}
|
||||
${BUILD_PATH}/snappy_command -i $DATA_PATH/${WAYID2NODEIDS_MAPPING_FILE} -o $DATA_PATH/${WAYID2NODEIDS_MAPPING_FILE_COMPRESSED}
|
||||
ls -lh $DATA_PATH/
|
||||
|
||||
# clean source pbf and temp .osrm
|
||||
rm -f $DATA_PATH/${MAPDATA_NAME_WITH_SUFFIX}.osm.pbf
|
||||
rm -f $DATA_PATH/${MAPDATA_NAME_WITH_SUFFIX}.osrm
|
||||
rm -f $DATA_PATH/${WAYID2NODEIDS_MAPPING_FILE}
|
||||
|
||||
# package and publish compiled mapdata
|
||||
if [ ${GENERATE_DATA_PACKAGE} == "true" ]; then
|
||||
|
||||
5
traffic_updater/.gitignore
vendored
5
traffic_updater/.gitignore
vendored
@ -1,4 +1,9 @@
|
||||
|
||||
# binaries
|
||||
go/osrm_traffic_updater/osrm_traffic_updater
|
||||
go/wayid2nodeid_extractor/wayid2nodeid_extractor
|
||||
go/snappy_command/snappy_command
|
||||
|
||||
*.py[cod]
|
||||
|
||||
traffic.csv
|
||||
|
||||
12
traffic_updater/go/go.mod
Normal file
12
traffic_updater/go/go.mod
Normal file
@ -0,0 +1,12 @@
|
||||
module github.com/Telenav/osrm-backend/traffic_updater/go
|
||||
|
||||
go 1.12
|
||||
|
||||
require (
|
||||
github.com/apache/thrift v0.12.0
|
||||
github.com/golang/protobuf v1.3.2 // indirect
|
||||
github.com/golang/snappy v0.0.1
|
||||
github.com/qedus/osmpbf v1.1.0
|
||||
)
|
||||
|
||||
replace github.com/Telenav/osrm-backend/traffic_updater/go/gen-go/proxy => ./gen-go/proxy
|
||||
8
traffic_updater/go/go.sum
Normal file
8
traffic_updater/go/go.sum
Normal file
@ -0,0 +1,8 @@
|
||||
github.com/apache/thrift v0.12.0 h1:pODnxUFNcjP9UTLZGTdeh+j16A8lJbRvD3rOtrk/7bs=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/qedus/osmpbf v1.1.0 h1:1ewnhb7cX0VAp24M+ViDvLI9RKKgZOXFBLM5xGlB5TA=
|
||||
github.com/qedus/osmpbf v1.1.0/go.mod h1:37EgzlwZC2inPP5/rY1MZIxE6kgDof7MIljJuELs0c0=
|
||||
Loading…
Reference in New Issue
Block a user