2017-10-31 23:31:32 -04:00
|
|
|
FROM alpine:3.6 as buildstage
|
2017-03-10 07:00:06 -05:00
|
|
|
|
2017-10-31 23:31:32 -04:00
|
|
|
ARG DOCKER_TAG
|
|
|
|
RUN mkdir -p /src && mkdir -p /opt
|
|
|
|
COPY . /src
|
|
|
|
WORKDIR /src
|
2017-05-29 06:08:44 -04:00
|
|
|
|
2017-03-10 07:00:06 -05:00
|
|
|
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 && \
|
2017-09-25 05:18:21 -04:00
|
|
|
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 && \
|
2017-10-31 23:31:32 -04:00
|
|
|
NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \
|
2017-03-21 15:53:12 -04:00
|
|
|
echo "Building OSRM ${DOCKER_TAG}" && \
|
2017-04-28 10:20:37 -04:00
|
|
|
git show --format="%H" | head -n1 > /opt/OSRM_GITSHA && \
|
2017-05-05 09:55:48 -04:00
|
|
|
echo "Building OSRM gitsha $(cat /opt/OSRM_GITSHA)" && \
|
2017-10-31 23:31:32 -04:00
|
|
|
mkdir -p build && \
|
2017-03-10 07:00:06 -05:00
|
|
|
cd build && \
|
2017-05-29 06:08:44 -04:00
|
|
|
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 && \
|
2017-03-10 07:00:06 -05:00
|
|
|
make -j${NPROC} install && \
|
|
|
|
cd ../profiles && \
|
|
|
|
cp -r * /opt && \
|
|
|
|
\
|
|
|
|
strip /usr/local/bin/* && \
|
2017-10-31 23:31:32 -04:00
|
|
|
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
|
|
|
|
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
|
|
|
|
WORKDIR /opt
|
2017-03-10 07:00:06 -05:00
|
|
|
|
|
|
|
EXPOSE 5000
|