diff --git a/Dockerfile b/docker/Dockerfile similarity index 84% rename from Dockerfile rename to docker/Dockerfile index d9991550b..98fe713f3 100644 --- a/Dockerfile +++ b/docker/Dockerfile @@ -1,11 +1,15 @@ FROM alpine:3.5 +ARG DOCKER_TAG + RUN mkdir /src COPY . /src RUN mkdir /opt WORKDIR /opt RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ + case ${DOCKER_TAG} in *"-debug"*) BUILD_TYPE="Debug";; *) BUILD_TYPE="Release";; esac && \ + \ echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \ apk update && \ apk upgrade && \ @@ -21,11 +25,11 @@ RUN NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) && \ make -j${NPROC} && \ make install && \ \ - echo "Building OSRM" &&\ + echo "Building OSRM ${DOCKER_TAG}" && \ cd /src && \ mkdir build && \ cd build && \ - cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_LTO=On .. && \ + cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DENABLE_LTO=On .. && \ make -j${NPROC} install && \ cd ../profiles && \ cp -r * /opt && \ diff --git a/docker/hooks/build b/docker/hooks/build new file mode 100644 index 000000000..d1eac8ab0 --- /dev/null +++ b/docker/hooks/build @@ -0,0 +1,9 @@ +#!/bin/sh + +# We've placed the Dockerfile under docker/ so that the generically named +# hooks/ directory doesn't pollute the main directory. Because we need to +# COPY the source into the container, we need to use some -f gymnastics to +# ensure that "COPY . /src" is referring to the repo root, not the directory +# that contains the Dockerfile. +# This script gets executed with a pwd of wherever the Dockerfile is. +docker build --build-arg DOCKER_TAG=${DOCKER_TAG} -t $IMAGE_NAME -f Dockerfile ..