1 Star 0 Fork 0

Collin/docker-python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
set -e
usage() {
cat << EOF
Usage: $0 [OPTIONS]
Build a new Python Docker image.
Options:
-g, --gpu Build an image with GPU support.
-c, --use-cache Use layer cache when building a new image.
-b, --base-image-tag TAG Base image tag. Defaults to value defined in DOCKERFILE.
EOF
}
CACHE_FLAG='--no-cache'
DOCKERFILE='Dockerfile'
IMAGE_TAG='kaggle/python-build'
BUILD_ARGS=''
while :; do
case "$1" in
-h|--help)
usage
exit
;;
-g|--gpu)
IMAGE_TAG='kaggle/python-gpu-build'
DOCKERFILE='gpu.Dockerfile'
;;
-c|--use-cache)
CACHE_FLAG=''
;;
-b|--base-image-tag)
if [[ -z $2 ]]; then
usage
printf 'ERROR: No TAG specified after the %s flag.\n' "$1" >&2
exit
fi
BUILD_ARGS="--build-arg BASE_TAG=$2"
shift # skip the flag value
;;
-?*)
usage
printf 'ERROR: Unknown option: %s\n' "$1" >&2
exit
;;
*)
break
esac
shift
done
BUILD_ARGS+=" --build-arg GIT_COMMIT=$(git rev-parse HEAD)"
BUILD_ARGS+=" --build-arg BUILD_DATE=$(date '+%Y%m%d-%H%M%S')"
readonly CACHE_FLAG
readonly DOCKERFILE
readonly IMAGE_TAG
readonly BUILD_ARGS
set -x
docker build --rm --pull $CACHE_FLAG -t "$IMAGE_TAG" -f "$DOCKERFILE" $BUILD_ARGS .
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zgxtech_admin/docker-python.git
git@gitee.com:zgxtech_admin/docker-python.git
zgxtech_admin
docker-python
docker-python
master

搜索帮助