Created
February 16, 2018 18:10
-
-
Save paco-valdez/245be57e4c368e1e71c239a39176ec97 to your computer and use it in GitHub Desktop.
OSRM Fragate Docker Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.6 as buildstage | |
ARG DOCKER_TAG | |
RUN mkdir -p /src && mkdir -p /opt | |
COPY . /src | |
WORKDIR /src | |
RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ | |
echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ | |
apk update && \ | |
apk upgrade && \ | |
apk add git cmake wget make libc-dev gcc g++ bzip2-dev boost-dev zlib-dev expat-dev lua5.2-dev libtbb@testing libtbb-dev@testing && \ | |
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ | |
echo "Building OSRM ${DOCKER_TAG}" && \ | |
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \ | |
echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \ | |
mkdir -p build && \ | |
cd build && \ | |
BUILD_TYPE="Release" && \ | |
ENABLE_ASSERTIONS="Off" && \ | |
BUILD_TOOLS="Off" && \ | |
case ${DOCKER_TAG} in *"-debug"*) BUILD_TYPE="Debug";; esac && \ | |
case ${DOCKER_TAG} in *"-assertions"*) BUILD_TYPE="RelWithDebInfo" && ENABLE_ASSERTIONS="On" && BUILD_TOOLS="On";; esac && \ | |
echo "Building ${BUILD_TYPE} with ENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} BUILD_TOOLS=${BUILD_TOOLS}" && \ | |
cmake .. -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_ASSERTIONS=${ENABLE_ASSERTIONS} -DBUILD_TOOLS=${BUILD_TOOLS} -DENABLE_LTO=On && \ | |
make -j${NPROC} install && \ | |
cd ../profiles && \ | |
cp -r * /opt && \ | |
\ | |
strip /usr/local/bin/* && \ | |
rm -rf /src /usr/local/lib/libosrm* | |
# Multistage build to reduce image size - https://docs.docker.com/engine/userguide/eng-image/multistage-build/#use-multi-stage-builds | |
# Only the content below ends up in the image, this helps remove /src from the image (which is large) | |
FROM alpine:3.6 as runstage | |
RUN mkdir -p /src && mkdir -p /opt && mkdir -p /data | |
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ | |
apk update && \ | |
apk add boost-filesystem boost-program_options boost-regex boost-iostreams boost-thread libgomp lua5.2 expat libtbb@testing | |
COPY --from=buildstage /usr/local /usr/local | |
COPY --from=buildstage /opt /opt | |
COPY data/* /data/ | |
WORKDIR /opt | |
EXPOSE 5000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment