From 5ca5e344c4e7f492729c9c6ef79aef4d57c0da41 Mon Sep 17 00:00:00 2001 From: Shoichi Kaji Date: Fri, 16 Aug 2024 22:09:29 +0900 Subject: [PATCH] use docker build --ouput --- .github/workflows/build.yml | 6 ++---- .github/workflows/release.yml | 6 ++---- build/Dockerfile | 15 +++++++++++---- build/github-actions.sh | 22 ---------------------- 4 files changed, 15 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 293333d..f65a50f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,8 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: docker build -t skaji/relocatable-perl -f build/Dockerfile . - - run: bash build/github-actions.sh linux_amd64_create_artifacts + - run: docker build -o linux-amd64 -f build/Dockerfile . - uses: actions/upload-artifact@v4 with: name: linux-amd64 @@ -25,8 +24,7 @@ jobs: - uses: actions/checkout@v4 - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - - run: docker buildx build --platform linux/arm64 -t skaji/relocatable-perl -f build/Dockerfile --load . - - run: bash build/github-actions.sh linux_arm64_create_artifacts + - run: docker buildx build --platform linux/arm64 -o linux-arm64 -f build/Dockerfile --load . - uses: actions/upload-artifact@v4 with: name: linux-arm64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b9ff1a..1ef13ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: docker build -t skaji/relocatable-perl -f build/Dockerfile . - - run: bash build/github-actions.sh linux_amd64_create_artifacts + - run: docker build -o linux-amd64 -f build/Dockerfile . - uses: actions/upload-artifact@v4 with: name: linux-amd64 @@ -22,8 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: docker/setup-qemu-action@v3 - uses: docker/setup-buildx-action@v3 - - run: docker buildx build --platform linux/arm64 -t skaji/relocatable-perl -f build/Dockerfile --load . - - run: bash build/github-actions.sh linux_arm64_create_artifacts + - run: docker buildx build --platform linux/arm64 -o linux-arm64 -f build/Dockerfile --load . - uses: actions/upload-artifact@v4 with: name: linux-arm64 diff --git a/build/Dockerfile b/build/Dockerfile index cb0bb81..2fbba7c 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,8 +1,12 @@ -FROM centos:centos7 +FROM centos:centos7 AS builder # see https://gist.github.com/skaji/76203327b517cb44da88a4301de118d3 RUN sed -i 's/override_install_langs=en_US.UTF-8/override_install_langs=en_US.utf8/' /etc/yum.conf +# https://stackoverflow.com/questions/78692851/could-not-retrieve-mirrorlist-http-mirrorlist-centos-org-release-7arch-x86-6 +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* +RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + RUN yum install -y \ gcc \ make \ @@ -21,9 +25,8 @@ RUN mkdir -p \ /usr/local/lib64 RUN curl -fsSL https://raw.githubusercontent.com/skaji/relocatable-perl/main/perl-install | bash -s /perl RUN curl -fsSL --compressed -o /cpm https://raw.githubusercontent.com/skaji/cpm/main/cpm -COPY build/relocatable-perl-build build/cpm.yml BUILD_VERSION / -RUN /perl/bin/perl /cpm install -g -RUN /perl/bin/perl /relocatable-perl-build --perl_version $(cat /BUILD_VERSION) --prefix /opt/perl +RUN --mount=type=bind,target=src /perl/bin/perl /cpm install -g --cpmfile src/build/cpm.yml +RUN --mount=type=bind,target=src /perl/bin/perl src/build/relocatable-perl-build --perl_version $(cat src/BUILD_VERSION) --prefix /opt/perl RUN /opt/perl/bin/perl /cpm install -g App::cpanminus App::ChangeShebang RUN /opt/perl/bin/change-shebang -f /opt/perl/bin/* RUN set -eux; \ @@ -34,3 +37,7 @@ RUN set -eux; \ gzip -9 --stdout perl-linux-$_ARCHNAME.tar > /perl-linux-$_ARCHNAME.tar.gz; \ xz -9 --stdout perl-linux-$_ARCHNAME.tar > /perl-linux-$_ARCHNAME.tar.xz; \ : + +FROM scratch +COPY --from=builder /perl-linux-*.tar.gz / +COPY --from=builder /perl-linux-*.tar.xz / diff --git a/build/github-actions.sh b/build/github-actions.sh index 1d4e12e..9c818ac 100644 --- a/build/github-actions.sh +++ b/build/github-actions.sh @@ -35,22 +35,6 @@ mac_create_artifacts() { xz -9 --stdout perl-darwin-$archname.tar > darwin-$archname/perl-darwin-$archname.tar.xz } -linux_amd64_create_artifacts() { - mkdir linux-amd64 - ID=$(docker create skaji/relocatable-perl) - docker cp $ID:/perl-linux-amd64.tar.gz linux-amd64/ - docker cp $ID:/perl-linux-amd64.tar.xz linux-amd64/ - docker rm $ID -} - -linux_arm64_create_artifacts() { - mkdir linux-arm64 - ID=$(docker create --platform linux/arm64 skaji/relocatable-perl) - docker cp $ID:/perl-linux-arm64.tar.gz linux-arm64/ - docker cp $ID:/perl-linux-arm64.tar.xz linux-arm64/ - docker rm $ID -} - case "$1" in mac_prepare_tools) mac_prepare_tools @@ -61,12 +45,6 @@ mac_build_perl) mac_create_artifacts) mac_create_artifacts ;; -linux_amd64_create_artifacts) - linux_amd64_create_artifacts - ;; -linux_arm64_create_artifacts) - linux_arm64_create_artifacts - ;; *) echo "unknown command: $1" >&2 exit 1