diff --git a/.github/Disable/.gitignore b/.github/Disable/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/.gitignore b/.github/workflows/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 0589ccb..c6fa4c3 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -29,6 +29,9 @@ jobs: - name: Build .jar file run: python build_with_docker.py + - name: Check is Build Success + run: ls group-center-docker.jar + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker BuildX diff --git a/.gitignore b/.gitignore index 9becaa4..400b778 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ out/ ### Kotlin ### .kotlin + +.env.act diff --git a/.run/act.docker.run.xml b/.run/act.docker.run.xml new file mode 100644 index 0000000..8866338 --- /dev/null +++ b/.run/act.docker.run.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/.run/build-clear.run.xml b/.run/build-clear.run.xml new file mode 100644 index 0000000..6ed4247 --- /dev/null +++ b/.run/build-clear.run.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/Docker/Dockerfile-Build b/Docker/Dockerfile-Build index b3e96cc..ee38531 100644 --- a/Docker/Dockerfile-Build +++ b/Docker/Dockerfile-Build @@ -18,7 +18,14 @@ ENV RUN_IN_DOCKER=True WORKDIR "$BASE_PATH" +# Install Software RUN yum update -y \ - && yum install -y git python3 python3-pip + && yum install -y git python3 python3-pip bash tzdata net-tools \ + && yum clean all + +# Set the timezone +ENV TZ=Asia/Shanghai +RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime \ + && echo ${TZ} > /etc/timezone ENTRYPOINT ["python3", "/usr/local/group-center/build.py", "--clean-cache"] diff --git a/Dockerfile b/Dockerfile index 3e10eb0..23d206e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,23 @@ FROM dragonwell-registry.cn-hangzhou.cr.aliyuncs.com/dragonwell/dragonwell:21-an # MAINTAINER Haomin Kong LABEL maintainer="Haomin Kong" +# https://mirrors.nwafu.edu.cn/help/local-repository/anolis/ +#RUN sed -e 's|^mirrorlist=|#mirrorlist=|g' \ +# -e 's|^#http://mirrors.openanolis.cn/|https://mirrors.nwafu.edu.cn/|g' \ +# -i.bak \ +# /etc/yum.repos.d/AnolisOS-AppStream.repo \ +# /etc/yum.repos.d/AnolisOS-DDE.repo \ +# /etc/yum.repos.d/AnolisOS-HighAvailability.repo \ +# /etc/yum.repos.d/AnolisOS-PowerTools.repo \ +# /etc/yum.repos.d/AnolisOS-BaseOS.repo \ +# /etc/yum.repos.d/AnolisOS-Plus.repo \ +# && sed -e 's|^mirrorlist=|#mirrorlist=|g' \ +# -e 's|^#https://mirrors.openanolis.cn/|https://mirrors.nwafu.edu.cn/|g' \ +# -i.bak \ +# /etc/yum.repos.d/AnolisOS-Debuginfo.repo \ +# /etc/yum.repos.d/AnolisOS-Source.repo \ +# && yum makecache + # Install Software RUN yum update -y \ && yum install -y tzdata net-tools \ diff --git a/act.docker.py b/act.docker.py new file mode 100644 index 0000000..4370445 --- /dev/null +++ b/act.docker.py @@ -0,0 +1,8 @@ +import os + +command = """ +act push\ + --secret-file .env.act +""" + +os.system(command.strip()) diff --git a/build.py b/build.py index db46206..648d6b9 100644 --- a/build.py +++ b/build.py @@ -70,16 +70,12 @@ def main(): print("Build failed!!!") exit(1) - if opt.clean_cache: - print("Cleaning Cache") - for cache_dir in cache_dir_list: - if os.path.exists(cache_dir): - shutil.rmtree(cache_dir) - jar_path = get_jar_path() if jar_path == "": print("Jar not found") return + else: + print(f"Jar Path: {jar_path}") # Remove Old if os.path.exists(target_path): @@ -88,6 +84,12 @@ def main(): # Copy to ./group-center-docker.jar shutil.copy(jar_path, target_path) + if opt.clean_cache: + print("Cleaning Cache") + for cache_dir in cache_dir_list: + if os.path.exists(cache_dir): + shutil.rmtree(cache_dir) + if __name__ == '__main__': main() diff --git a/build_with_docker.py b/build_with_docker.py index 613783b..0272ab0 100644 --- a/build_with_docker.py +++ b/build_with_docker.py @@ -1,4 +1,24 @@ import os +import subprocess + + +def run_command(command): + command_list = command.split(" ") + command_list = [ + item.strip() + for item in command_list + if len(item.strip()) > 0 + ] + print("Run Command: ", command_list) + with subprocess.Popen(command_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=1, + universal_newlines=True) as process: + for line in process.stdout: + print(line, end='') # 实时打印输出 + + exit_code = process.wait() + + return exit_code == 0 + image_name = "group-center-builder" print("=" * 20) @@ -8,17 +28,36 @@ # Build Image print("=" * 20) print("== Build Image") -os.system(f"docker build -t {image_name} -f Docker/Dockerfile-Build .") +if not run_command(f"docker build -t {image_name} -f ./Docker/Dockerfile-Build ."): + print("Build Image Failed") + exit(1) + +# Check Build Scripts +print("=" * 20) +print("== Check Build Scripts") +if os.path.exists("./build.py"): + print("Build Scripts Exists") +else: + print("Build Scripts Not Exists") + exit(1) # Run Containers print("=" * 20) print("== Run Containers") -os.system(f"docker run --rm -v .:/usr/local/group-center {image_name}") +# Get Work Dir +# work_dir = os.getcwd() +# py_file_path = os.path.abspath(__file__) +# work_dir = os.path.dirname(py_file_path) +# print("Work Dir: ", work_dir) +# if not run_command(f"docker run --rm -v {work_dir}:/usr/local/group-center {image_name}"): +if not run_command(f"docker run --rm -v .:/usr/local/group-center {image_name}"): + print("Run Containers Failed") + exit(1) # Remove Image print("=" * 20) print("== Remove Image") -os.system(f"docker rmi {image_name}") +run_command(f"docker rmi {image_name}") # Done print("=" * 20)