Skip to content

Commit

Permalink
Merge pull request #785 from jingjingxyk/experiment-feature
Browse files Browse the repository at this point in the history
Experiment feature
  • Loading branch information
jingjingxyk committed Sep 17, 2024
2 parents de2ab80 + 43b6aa3 commit 225c5cd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
8 changes: 3 additions & 5 deletions sapi/docker/build-export-container.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

: <<'COMMENT'
Expand All @@ -18,6 +18,8 @@ __PROJECT__=$(
cd ${__DIR__}
cd ${__PROJECT__}

# alpine 基础镜像 支持多架构

CONTAINER_BASE_IMAGE='docker.io/library/alpine:3.18'
CONTAIENR_NAME='swoole-cli-builder'
MIRROR=''
Expand All @@ -40,10 +42,6 @@ while [ $# -gt 0 ]; do
--mirror)
MIRROR="$2"
;;
--quickstart-container)
CONTAIENR_NAME='swoole-cli-alpine-dev'
# 从quickstart 生成的容器中拷贝 /usr/local/swoole-cli/ 文件夹,并生成新容器镜像
;;
--*)
echo "Illegal option $1"
;;
Expand Down
9 changes: 4 additions & 5 deletions sapi/quickstart/linux/alpine-init-minimal.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env sh

set -exu
__DIR__=$(
Expand All @@ -10,7 +10,6 @@ cd ${__DIR__}
# use china mirror
# sh sapi/quickstart/linux/alpine-init-mini.sh --mirror [ china | ustc | tuna | tencentyun | huaweicloud ]


MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
Expand All @@ -28,8 +27,8 @@ case "$MIRROR" in
china | tuna | ustc)
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
test "$MIRROR" = "china" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
;;
tencentyun | huaweicloud) # 云服务的内网镜像源
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
Expand All @@ -41,4 +40,4 @@ esac

apk update

apk add bash git curl wget xz zip unzip ca-certificates
apk add bash git curl wget xz zip unzip ca-certificates
9 changes: 4 additions & 5 deletions sapi/quickstart/linux/alpine-init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env sh

set -exu
__DIR__=$(
Expand All @@ -10,7 +10,6 @@ cd ${__DIR__}
# use china mirror
# sh sapi/quickstart/linux/alpine-init.sh --mirror [ china | ustc | tuna | tencentyun | huaweicloud ]


MIRROR=''
while [ $# -gt 0 ]; do
case "$1" in
Expand All @@ -28,8 +27,8 @@ case "$MIRROR" in
china | tuna | ustc)
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
test "$MIRROR" = "china" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "tuna" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
test "$MIRROR" = "ustc" && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
;;
tencentyun | huaweicloud) # 云服务的内网镜像源
test -f /etc/apk/repositories.save || cp /etc/apk/repositories /etc/apk/repositories.save
Expand All @@ -56,7 +55,6 @@ apk add diffutils
apk add netcat-openbsd socat
apk add python3-dev
apk add mercurial
apk add gettext-dev

case "$MIRROR" in
china | tuna | ustc)
Expand All @@ -66,6 +64,7 @@ china | tuna | ustc)
tencentyun | huaweicloud)
test "$MIRROR" = "tencentyun" && pip3 config set global.index-url https://mirrors.tencentyun.com/pypi/simple/
test "$MIRROR" = "huaweicloud" && pip3 config set global.index-url https://repo.huaweicloud.com/pypi/simple/
;;
esac

# pip3 install meson
Expand Down
11 changes: 0 additions & 11 deletions sapi/src/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,6 @@ public function getBaseImageTag(): string
return 'base' . '-' . $arch;
}
}

public function getBaseImageDockerFile(): string
{
$arch = $this->getSystemArch();
if ($arch == 'x64') {
return 'Dockerfile';
} else {
return 'Dockerfile' . '-' . $arch;
}
}

public function setPhpSrcDir(string $phpSrcDir)
{
$this->phpSrcDir = $phpSrcDir;
Expand Down
13 changes: 11 additions & 2 deletions sapi/src/template/make.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@
}

help() {
set +x
echo "./make.sh docker-build [ china | ustc | tuna ]"
echo "./make.sh docker-bash"
echo "./make.sh docker-commit"
Expand Down Expand Up @@ -405,10 +404,20 @@
;;
esac
fi
PLATFORM=''
ARCH=$(uname -m)
case $ARCH in
'x86_64')
PLATFORM='linux/amd64'
;;
'aarch64')
PLATFORM='linux/arm64'
;;
esac
cd ${__PROJECT_DIR__}/sapi/docker
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}" --build-arg="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)
Expand Down

0 comments on commit 225c5cd

Please sign in to comment.