-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use
Dockerfile
for reproducible build
The reproducibility of td-shim is limited by the same system user and source code path, so we can use Docker container to reproduce binaries. Signed-off-by: Jiaqi Gao <[email protected]>
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
FOLDER="" | ||
|
||
usage() { | ||
cat << EOM | ||
Usage: $(basename "$0") [OPTION]... | ||
-d <docker file> Path of Dockerfile. | ||
EOM | ||
} | ||
|
||
error() { | ||
echo -e "\e[1;31mERROR: $*\e[0;0m" | ||
exit 1 | ||
} | ||
|
||
process_args() { | ||
while getopts ":f:h" option; do | ||
case "$option" in | ||
f) FOLDER=$OPTARG;; | ||
h) usage | ||
exit 0 | ||
;; | ||
*) | ||
echo "Invalid option '-$OPTARG'" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z ${FOLDER} ]]; then | ||
error "Please specify the folder of where the Dockerfile is located through -f." | ||
fi | ||
|
||
if [[ ! -f "${FOLDER}/Dockerfile" ]]; then | ||
error "Dockerfile does not exist." | ||
fi | ||
} | ||
|
||
process_args $@ | ||
|
||
pushd ${FOLDER} | ||
|
||
# If the docker image does not exist, build the docker image | ||
set +e && docker image inspect tdshim.build.env:latest > /dev/null 2>&1 && set -e | ||
if [ $? != 0 ]; then | ||
docker build -t tdshim.build.env \ | ||
--build-arg https_proxy=$https_proxy \ | ||
--build-arg http_proxy=$http_proxy \ | ||
. | ||
fi | ||
|
||
popd | ||
|
||
# Run the docker image | ||
docker run -it --rm tdshim.build.env |