aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorThibaut Goetghebuer-Planchon <thibaut.goetghebuer-planchon@arm.com>2022-07-06 10:23:22 +0100
committerThibaut Goetghebuer-Planchon <thibaut.goetghebuer-planchon@arm.com>2022-08-18 14:35:45 +0100
commit52dacd6556d60815253d4e4938e218ea3d8084a2 (patch)
tree4c470c567da6f70f65987d5af161bf4f950d107b /docker
parentcc5d89eea4ff3dc398cac3b6025450f48ac20c1e (diff)
downloadtosa_checker-52dacd6556d60815253d4e4938e218ea3d8084a2.tar.gz
Initial commit0.1.0-rc.1
Change-Id: I2fb0933d595a6ede6417d09dd905ef72d6c60c9b
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile26
-rw-r--r--docker/README.md52
-rwxr-xr-xdocker/install/install_bazel.sh24
3 files changed, 102 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..4481565
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,26 @@
+# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+FROM quay.io/pypa/manylinux2014_x86_64
+
+ARG PYTHON_VERSION=3.9
+ARG TENSORFLOW_VERSION=2.9.0
+ARG BAZEL_VERSION=5.1.1
+
+RUN ln -s /opt/_internal/cpython-$PYTHON_VERSION*/bin/python3 /usr/local/bin/python3 && \
+ ln -s /opt/_internal/cpython-$PYTHON_VERSION*/bin/python /usr/local/bin/python && \
+ ln -s /opt/_internal/cpython-$PYTHON_VERSION*/bin/pip3 /usr/local/bin/pip3 && \
+ ln -s /opt/_internal/cpython-$PYTHON_VERSION*/bin/pip /usr/local/bin/pip && \
+ ln -s /opt/_internal/cpython-$PYTHON_VERSION*/include/python${PYTHON_VERSION}/ /usr/local/include/python
+
+ENV PYTHON_BIN_PATH=/usr/local/bin/python
+ENV CI_BUILD_PYTHON=/usr/local/bin/python
+ENV CROSSTOOL_PYTHON_INCLUDE_PATH=/usr/local/include/python/
+
+RUN pip install --no-cache-dir setuptools pybind11 numpy twine keyrings.alt
+
+COPY install/install_bazel.sh /install/
+RUN /install/install_bazel.sh ${BAZEL_VERSION}
+
+# CACHE_STOP is used to rerun future commands, otherwise the cloning will be cached and will not pull the most recent version
+ARG CACHE_STOP=1
+RUN git clone --depth=1 https://github.com/tensorflow/tensorflow.git --branch v${TENSORFLOW_VERSION} /tensorflow_src
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..653b9a2
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,52 @@
+<!---
+SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+SPDX-License-Identifier: Apache-2.0
+--->
+# Docker™ image
+
+This directory contains different utilities to build/test the TOSA Checker.
+
+## How to build the TOSA Checker manylinux wheel with a Docker™ image
+
+To create a Docker™ image for the TOSA Checker to build it for Python® 3.9 on various Linux® distributions, please run the following command:
+
+```console
+docker build . -t tc-cp39-manylinux --build-arg PYTHON_VERSION=3.9 -f Dockerfile
+```
+
+The TensorFlow™ source code is automatically downloaded and is located in the `/tensorflow_src` directory.
+
+The command to run the container is:
+
+```console
+docker run -it -v <tosa_checker source code on your machine>:/tosa_checker tc-cp39-manylinux
+```
+
+Now call the following command to build a `tosa_checker` Python® wheel inside of the container:
+
+```console
+cd tosa_checker
+python3 setup.py --tensorflow_src_dir /tensorflow_src bdist_wheel
+```
+The `tosa_checker` wheel can be found in the `/dist` directory.
+
+Generate the new manylinux wheel from the `tosa_checker` wheel:
+```console
+auditwheel repair dist/<tosa_checker>.whl -w dist/
+```
+The `tosa_checker` manylinux wheel can now be found in the `/dist` directory.
+
+Install the `tosa_checker` manylinux wheel:
+```console
+pip install dist/<tosa_checker-manyliux>.whl
+```
+
+## Trademarks and Copyrights
+
+Python® is a registered trademark of the PSF.
+Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
+Ubuntu® is a registered trademark of Canonical.
+TensorFlow™ is a trademark of Google® LLC.
+Docker™ is a trademark of Docker, Inc.
+
+
diff --git a/docker/install/install_bazel.sh b/docker/install/install_bazel.sh
new file mode 100755
index 0000000..687ed13
--- /dev/null
+++ b/docker/install/install_bazel.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
+# SPDX-License-Identifier: Apache-2.0
+BAZEL_VERSION="$1"
+shift
+
+set +e
+local_bazel_ver=$(bazel version 2>&1 | grep -i label | awk '{print $3}')
+
+if [[ "$local_bazel_ver" == "$BAZEL_VERSION" ]]; then
+ exit 0
+fi
+
+set -e
+
+# Install Bazel™
+mkdir -p /bazel
+cd /bazel
+if [[ ! -f "bazel-$BAZEL_VERSION-installer-linux-x86_64.sh" ]]; then
+ curl -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
+fi
+chmod +x /bazel/bazel-*.sh
+/bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
+rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh