Skip to content

Commit bd71c4e

Browse files
michelperiknw
andauthored
Test dockerfile (#14)
* Update to SuiteSparse:GraphBLAS 5.0.3. Also, add sanity check to make sure all GrB and GxB lines are handled. This would have caught the issue of the new functions not being public in v5.0.2. * test dockerfile * test dockerfile * test dockerfile * clean up apt, move toward multi stage * multistage docker file down to 227MB * add docker build script. Co-authored-by: Erik Welch <[email protected]>
1 parent 8664b12 commit bd71c4e

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile

Dockerfile

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
ARG BASE_CONTAINER=python:3.9-slim-buster
2+
FROM ${BASE_CONTAINER} as suitesparse
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
RUN apt-get update && apt-get install -yq build-essential cmake git
6+
7+
ARG SUITESPARSE
8+
ARG COMPACT
9+
10+
WORKDIR /build
11+
RUN git clone https://github.com/eliben/pycparser.git --depth 1
12+
13+
WORKDIR /build/GraphBLAS/build
14+
RUN git clone https://github.com/DrTimothyAldenDavis/GraphBLAS.git --depth 1 --branch v${SUITESPARSE} \
15+
&& cd GraphBLAS/build \
16+
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DGBCOMPACT=${COMPACT} \
17+
&& make -j$(nproc) \
18+
&& make install
19+
20+
FROM ${BASE_CONTAINER} as psg
21+
ARG SUITESPARSE
22+
ARG VERSION
23+
ENV PYTHONUNBUFFERED 1
24+
25+
COPY --from=suitesparse /usr/include/GraphBLAS.h /usr/local/include/
26+
COPY --from=suitesparse /usr/lib/x86_64-linux-gnu/libgraphblas* /usr/lib/x86_64-linux-gnu/
27+
COPY --from=suitesparse /build/pycparser/utils/fake_libc_include/* /usr/local/lib/python3.9/site-packages/pycparser/utils/fake_libc_include/
28+
29+
RUN apt-get update && apt-get install -yq build-essential git
30+
RUN pip3 install numpy cffi pytest cython
31+
32+
RUN mkdir -p /build/python-suitesparse-graphblas
33+
ADD . /build/python-suitesparse-graphblas
34+
35+
WORKDIR /build/python-suitesparse-graphblas
36+
RUN git tag ${VERSION} && \
37+
python3 suitesparse_graphblas/create_headers.py && \
38+
python3 setup.py install && \
39+
ldconfig
40+
41+
WORKDIR /
42+
RUN pytest --pyargs suitesparse_graphblas.tests
43+
RUN apt-get -y --purge remove git python3-pip && apt-get clean
44+
45+
FROM ${BASE_CONTAINER}
46+
COPY --from=suitesparse /usr/lib/x86_64-linux-gnu/libgraphblas* /usr/lib/x86_64-linux-gnu/
47+
COPY --from=suitesparse /usr/lib/x86_64-linux-gnu/libgomp* /usr/lib/x86_64-linux-gnu/
48+
COPY --from=psg /usr/local/lib/python3.9/site-packages /usr/local/lib/python3.9/site-packages

docker_build.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
if [ $# -eq 0 ]
2+
then
3+
echo "Usage: ./docker_build.sh SUITESPARSE VERSION BRANCH [LOCATION PUSH]
4+
5+
Example: ./docker_build.sh 5.0.6 5.0.6.0 main clone push
6+
7+
If location is clone then a fresh git clone will be used.
8+
If push is provided then the script will attempt to push to dockerhub."
9+
exit 1
10+
fi
11+
12+
IMAGE=graphblas/python-suitesparse-graphblas
13+
SUITESPARSE=$1
14+
VERSION=$2
15+
BRANCH=$3
16+
LOCATION=$4
17+
PUSH=$5
18+
19+
COMPACT=${COMPACT:-0}
20+
21+
if [ "$LOCATION" = "clone" ]
22+
then
23+
TMPDIR=$(mktemp -d)
24+
if [ ! -e $TMPDIR ]; then
25+
>&2 echo "Failed to create temp directory"
26+
exit 1
27+
fi
28+
trap "exit 1" HUP INT PIPE QUIT TERM
29+
trap 'rm -rf "$TMPDIR"' EXIT
30+
31+
cd $TMPDIR
32+
git clone --branch $BRANCH https://github.com/GraphBLAS/python-suitesparse-graphblas.git
33+
cd python-suitesparse-graphblas
34+
fi
35+
36+
docker build \
37+
--build-arg SUITESPARSE=${SUITESPARSE} \
38+
--build-arg VERSION=${VERSION} \
39+
--build-arg COMPACT=${COMPACT} \
40+
-t $IMAGE:$VERSION \
41+
.
42+
43+
docker tag $IMAGE:$VERSION $IMAGE:latest
44+
45+
if [ "$PUSH" = "push" ]
46+
then
47+
docker push $IMAGE:$VERSION
48+
docker push $IMAGE:latest
49+
fi

0 commit comments

Comments
 (0)