Skip to content

Commit

Permalink
添加 开放原子 容器镜像 解决拉取基础镜像超时 (#767)
Browse files Browse the repository at this point in the history
* 添加 开放原子 容器镜像 解决拉取基础镜像超时

* update

* fix script error

* update make.sphp
  • Loading branch information
jingjingxyk authored Sep 20, 2024
1 parent c58cec7 commit 6595588
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
5 changes: 5 additions & 0 deletions sapi/docker/build-export-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ while [ $# -gt 0 ]; do
shift $(($# > 0 ? 1 : 0))
done

case "$MIRROR" in
china | openatom)
CONTAINER_BASE_IMAGE="hub.atomgit.com/library/alpine:3.18"
;;
esac

mkdir -p var/build-export-container/
cd ${__PROJECT__}/var/build-export-container/
Expand Down
16 changes: 16 additions & 0 deletions sapi/quickstart/linux/run-alpine-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,23 @@ cd ${__DIR__}
echo $?
}
cd ${__DIR__}

IMAGE=alpine:3.18

MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
--mirror)
MIRROR="$2"
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/alpine:3.18"
;;
esac
;;
esac
shift $(($# > 0 ? 1 : 0))
done

cd ${__DIR__}
docker run --rm --name swoole-cli-alpine-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null
18 changes: 17 additions & 1 deletion sapi/quickstart/linux/run-debian-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@ cd ${__DIR__}
echo $?
}
cd ${__DIR__}
IMAGE=debian:11

IMAGE=debian:12

MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
--mirror)
MIRROR="$2"
case "$MIRROR" in
china | openatom)
IMAGE="hub.atomgit.com/library/debian:12"
;;
esac
;;
esac
shift $(($# > 0 ? 1 : 0))
done


cd ${__DIR__}
docker run --rm --name swoole-cli-debian-dev -d -v ${__PROJECT__}:/work -w /work --init $IMAGE tail -f /dev/null
12 changes: 10 additions & 2 deletions sapi/src/template/make.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,14 @@

if [ "$1" = "docker-build" ] ;then
MIRROR=""
CONTAINER_BASE_IMAGE='docker.io/library/alpine:3.18'
if [ -n "$2" ]; then
MIRROR=$2
case "$MIRROR" in
china | openatom )
CONTAINER_BASE_IMAGE="hub.atomgit.com/library/alpine:3.18"
;;
esac
fi
PLATFORM=''
ARCH=$(uname -m)
Expand All @@ -331,13 +337,15 @@
;;
esac
cd ${__PROJECT_DIR__}/sapi/docker
docker build --no-cache -t <?= Preprocessor::IMAGE_NAME ?>:<?= $this->getBaseImageTag() ?> -f Dockerfile . --build-arg="MIRROR=${MIRROR}" --progress=plain --platform=${PLATFORM}
echo "MIRROR=${MIRROR}"
echo "BASE_IMAGE=${CONTAINER_BASE_IMAGE}"
docker build --no-cache -t <?= Preprocessor::IMAGE_NAME ?>:<?= $this->getBaseImageTag() ?> -f Dockerfile . --build-arg="MIRROR=${MIRROR}" --progress=plain --platform=${PLATFORM} --build-arg="BASE_IMAGE=${CONTAINER_BASE_IMAGE}"
exit 0
elif [ "$1" = "docker-bash" ] ;then
container=$(docker ps -a -f name=<?= Preprocessor::CONTAINER_NAME ?> | tail -n +2 2> /dev/null)
base_image=$(docker images <?= Preprocessor::IMAGE_NAME ?>:<?= $this->getBaseImageTag() ?> | tail -n +2 2> /dev/null)
image=$(docker images <?= Preprocessor::IMAGE_NAME ?>:<?= $this->getImageTag() ?> | tail -n +2 2> /dev/null)
CONTAINER_STATE=$(docker inspect -f {{.State.Running}} <?= Preprocessor::CONTAINER_NAME ?> 2> /dev/null)
CONTAINER_STATE=$(docker inspect -f "{{.State.Running}}" <?= Preprocessor::CONTAINER_NAME ?> 2> /dev/null)
if [[ "${CONTAINER_STATE}" != "true" ]]; then
bash ./make.sh docker-stop
container=''
Expand Down

0 comments on commit 6595588

Please sign in to comment.