Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加 开放原子 容器镜像 解决拉取基础镜像超时 #767

Merged
merged 5 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading