Skip to content

Commit

Permalink
Merge pull request #1185 from muzi502/gen-repository-iso
Browse files Browse the repository at this point in the history
Optimize the process of build repository iso
  • Loading branch information
ks-ci-bot authored Apr 12, 2022
2 parents 6a4ade0 + 86e1a6f commit 0fa9eda
Show file tree
Hide file tree
Showing 9 changed files with 339 additions and 51 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/gen-repository-iso.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
name: gen-repository-iso
on:
push:
tag:
- 'v*'
workflow_dispatch:

jobs:
build:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- name: centos7-rpms
dockerfile: dockerfile.centos7
- name: debian9-debs
dockerfile: dockerfile.debian9
- name: debian10-debs
dockerfile: dockerfile.debian10
- name: ubuntu-16.04-debs
dockerfile: dockerfile.ubuntu1604
- name: ubuntu-18.04-debs
dockerfile: dockerfile.ubuntu1804
- name: ubuntu-20.04-debs
dockerfile: dockerfile.ubuntu2004
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build iso image to local
uses: docker/build-push-action@v2
with:
context: hack/gen-repository-iso
file: hack/gen-repository-iso/${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
outputs: type=local,dest=./output

- name: Prepare for upload iso
shell: bash
run: |
mv ./output/linux_amd64/*.iso ${{ matrix.name }}-amd64.iso
mv ./output/linux_arm64/*.iso ${{ matrix.name }}-arm64.iso
sha256sum *.iso > ${{ matrix.name }}.iso.sha256sum.txt
- name: Wait for release workflow to finish
uses: lewagon/wait-on-check-action@v1.0.0
with:
ref: ${{ github.ref }}
check-name: 'goreleaser'
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
allowed-conclusions: success

- name: Release and upload packages
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
${{ matrix.name }}.iso.sha256sum.txt
${{ matrix.name }}-amd64.iso
${{ matrix.name }}-arm64.iso
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,21 @@ kk: fmt vet
-o bin/$(GOOS)/$(GOARCH)/kk ./cmd/main.go;

go-releaser-test:
goreleaser release --rm-dist --skip-publish --snapshot
goreleaser release --rm-dist --skip-publish --snapshot

# build the artifact of repository iso
ISO_ARCH ?= amd64
ISO_OUTPUT_DIR ?= ./output
ISO_BUILD_WORKDIR := hack/gen-repository-iso
ISO_OS_NAMES := centos7 debian9 debian10 ubuntu1604 ubuntu1804 ubuntu2004
ISO_BUILD_NAMES := $(addprefix build-iso-,$(ISO_OS_NAMES))
build-iso-all: $(ISO_BUILD_NAMES)
.PHONY: $(ISO_BUILD_NAMES)
$(ISO_BUILD_NAMES):
@export DOCKER_BUILDKIT=1
docker build \
--platform linux/$(ISO_ARCH) \
--build-arg TARGETARCH=$(ISO_ARCH) \
-o type=local,dest=$(ISO_OUTPUT_DIR) \
-f $(ISO_BUILD_WORKDIR)/dockerfile.$(subst build-iso-,,$@) \
$(ISO_BUILD_WORKDIR)
29 changes: 18 additions & 11 deletions hack/gen-repository-iso/dockerfile.centos7
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
FROM centos:centos7
FROM centos:7 as centos7
ARG TARGETARCH
ENV OS=centos
ENV OS_VERSION=7
ARG BUILD_TOOLS="yum-utils createrepo mkisofs epel-release"
ARG DIR=${OS}${OS_VERSION}-${TARGETARCH}-rpms

WORKDIR package
RUN yum install -q -y ${BUILD_TOOLS} \
&& yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo \
&& yum makecache

ENV DIR=centos-7-amd64-rpms
ENV DOCKERVERSION=20.10.8
WORKDIR package
COPY packages.yaml .
COPY --from=mikefarah/yq:4.11.1 /usr/bin/yq /usr/bin/yq
RUN yq eval ".common[],.rpms[],.${OS}[],.${OS}${OS_VERSION}" packages.yaml > packages.list

RUN mkdir ${DIR} && cd ${DIR} && \
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo && \
yumdownloader --resolve --destdir ./ docker-ce-${DOCKERVERSION} docker-ce-cli-${DOCKERVERSION} containerd.io \
nss nss-sysinit nss-tools lz4 chrony bind-utils nfs-utils net-tools ipvsadm ceph-common glusterfs-fuse yum-utils \
curl openssl socat conntrack ebtables ipset telnet lvm2 keepalived haproxy psmisc tcpdump && \
yum install createrepo mkisofs -y && createrepo ./
RUN sort -u packages.list | xargs repotrack -p ${DIR} \
&& createrepo -d ${DIR} \
&& mkisofs -r -o ${DIR}.iso ${DIR}

RUN mkisofs -r -o ${DIR}.iso ${DIR}
FROM scratch
COPY --from=centos7 /package/*.iso /
38 changes: 38 additions & 0 deletions hack/gen-repository-iso/dockerfile.debian10
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM debian:10 as debian10
ARG TARGETARCH
ARG OS_RELEASE=buster
ARG OS_VERSION=10
ARG DIR=debian-10-${TARGETARCH}-debs
ARG PKGS=.common[],.debs[],.debian[],.debian10[]
ARG BUILD_TOOLS="apt-transport-https software-properties-common ca-certificates curl wget gnupg dpkg-dev genisoimage dirmngr"
ENV DEBIAN_FRONTEND=noninteractive

# dump system package list
RUN dpkg --get-selections | grep -v deinstall | cut -f1 | cut -d ':' -f1 > packages.list
RUN ARCH=$(dpkg --print-architecture) \
&& apt update -qq \
&& apt install -y --no-install-recommends $BUILD_TOOLS \
&& if [ "$TARGETARCH" = "amd64" ]; then \
curl -fsSL https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub | apt-key add - ; \
echo deb https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/${OS_VERSION}/amd64/apt ${OS_RELEASE} main > /etc/apt/sources.list.d/gluster.list ; \
fi \
&& curl -fsSL "https://download.docker.com/linux/debian/gpg" | apt-key add -qq - \
&& echo "deb [arch=$TARGETARCH] https://download.docker.com/linux/debian ${OS_RELEASE} stable" > /etc/apt/sources.list.d/docker.list \
&& apt update -qq

WORKDIR /package
COPY packages.yaml .

COPY --from=mikefarah/yq:4.11.1 /usr/bin/yq /usr/bin/yq
RUN yq eval "${PKGS}" packages.yaml >> packages.list \
&& sort -u packages.list | xargs apt-get install --yes --reinstall --print-uris | awk -F "'" '{print $2}' | grep -v '^$' | sort -u > packages.urls

RUN mkdir -p ${DIR} \
&& wget -q -x -P ${DIR} -i packages.urls \
&& cd ${DIR} \
&& dpkg-scanpackages ./ /dev/null | gzip -9c > ./Packages.gz

RUN genisoimage -r -o ${DIR}.iso ${DIR}

FROM scratch
COPY --from=debian10 /package/*.iso /
37 changes: 37 additions & 0 deletions hack/gen-repository-iso/dockerfile.debian9
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM debian:9 as debian9
ARG TARGETARCH
ARG OS_RELEASE=stretch
ARG OS_VERSION=9
ARG DIR=debian-9-${TARGETARCH}-debs
ARG PKGS=.common[],.debs[],.debian[],.debian9[]
ARG BUILD_TOOLS="apt-transport-https software-properties-common ca-certificates curl wget gnupg dpkg-dev genisoimage dirmngr"
ENV DEBIAN_FRONTEND=noninteractive

# dump system package list
RUN dpkg --get-selections | grep -v deinstall | cut -f1 | cut -d ':' -f1 > packages.list
RUN apt update -qq \
&& apt install -y --no-install-recommends $BUILD_TOOLS \
&& if [ "$TARGETARCH" = "amd64" ]; then \
curl -fsSL https://download.gluster.org/pub/gluster/glusterfs/7/rsa.pub | apt-key add - ; \
echo deb https://download.gluster.org/pub/gluster/glusterfs/7/LATEST/Debian/${OS_VERSION}/amd64/apt ${OS_RELEASE} main > /etc/apt/sources.list.d/gluster.list ; \
fi \
&& curl -fsSL "https://download.docker.com/linux/debian/gpg" | apt-key add -qq - \
&& echo "deb [arch=$TARGETARCH] https://download.docker.com/linux/debian ${OS_RELEASE} stable" > /etc/apt/sources.list.d/docker.list \
&& apt update -qq

WORKDIR /package
COPY packages.yaml .

COPY --from=mikefarah/yq:4.11.1 /usr/bin/yq /usr/bin/yq
RUN yq eval "${PKGS}" packages.yaml >> packages.list \
&& sort -u packages.list | xargs apt-get install --yes --reinstall --print-uris | awk -F "'" '{print $2}' | grep -v '^$' | sort -u > packages.urls

RUN mkdir -p ${DIR} \
&& wget -q -x -P ${DIR} -i packages.urls \
&& cd ${DIR} \
&& dpkg-scanpackages ./ /dev/null | gzip -9c > ./Packages.gz

RUN genisoimage -r -o ${DIR}.iso ${DIR}

FROM scratch
COPY --from=debian9 /package/*.iso /
40 changes: 27 additions & 13 deletions hack/gen-repository-iso/dockerfile.ubuntu1604
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
FROM ubuntu:16.04
FROM ubuntu:16.04 as ubuntu1604
ARG TARGETARCH
ARG OS_RELEASE=xenial
ARG DIR=ubuntu-16.04-${TARGETARCH}-debs
ARG PKGS=.common[],.debs[],.ubuntu[],.ubuntu1604[]
ARG BUILD_TOOLS="apt-transport-https software-properties-common ca-certificates curl wget gnupg dpkg-dev genisoimage"
ENV DEBIAN_FRONTEND=noninteractive

WORKDIR package
# dump system package list
RUN dpkg --get-selections | grep -v deinstall | cut -f1 | cut -d ':' -f1 > packages.list
RUN apt update -qq \
&& apt install -y --no-install-recommends $BUILD_TOOLS \
&& add-apt-repository ppa:gluster/glusterfs-7 -y \
&& curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - \
&& echo "deb [arch=$TARGETARCH] https://download.docker.com/linux/ubuntu ${OS_RELEASE} stable" > /etc/apt/sources.list.d/docker.list\
&& apt update -qq

ENV DIR=ubuntu-16.04-amd64-debs
ENV DOCKERVERSION=5:20.10.7~3-0~ubuntu-xenial
ENV PACKAGES="apt-transport-https ca-certificates curl git gnupg-agent software-properties-common sudo openssl openssh-server socat conntrack ebtables ipset docker-ce=${DOCKERVERSION} docker-ce-cli=${DOCKERVERSION} containerd.io chrony ipvsadm nfs-common ceph-common glusterfs-client dnsutils telnet lvm2 keepalived haproxy psmisc tcpdump"
WORKDIR /package
COPY packages.yaml .

RUN mkdir ${DIR} && apt update && apt install curl sudo software-properties-common apt-transport-https -y && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable" && \
add-apt-repository ppa:gluster/glusterfs-7 -y && apt update
COPY --from=mikefarah/yq:4.11.1 /usr/bin/yq /usr/bin/yq
RUN yq eval "${PKGS}" packages.yaml >> packages.list \
&& sort -u packages.list | xargs apt-get install --yes --reinstall --print-uris | awk -F "'" '{print $2}' | grep -v '^$' | sort -u > packages.urls

ADD download-pkgs.sh ./${DIR}/
RUN mkdir -p ${DIR} \
&& wget -q -x -P ${DIR} -i packages.urls \
&& cd ${DIR} \
&& dpkg-scanpackages ./ /dev/null | gzip -9c > ./Packages.gz

RUN cd ${DIR} && sh download-pkgs.sh && rm -rf download-pkgs.sh && rm -rf
RUN genisoimage -r -o ${DIR}.iso ${DIR}

RUN apt install apt-utils dpkg-dev -y && cd ${DIR} && dpkg-scanpackages ./ /dev/null |gzip > ./Packages.gz

RUN apt-get install genisoimage -y && mkisofs -r -o ${DIR}.iso ${DIR}
FROM scratch
COPY --from=ubuntu1604 /package/*.iso /
41 changes: 28 additions & 13 deletions hack/gen-repository-iso/dockerfile.ubuntu1804
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
FROM ubuntu:18.04
FROM ubuntu:18.04 as ubuntu1804
ARG TARGETARCH
ARG OS_RELEASE=bionic
ARG DIR=ubuntu-18.04-${TARGETARCH}-debs
ARG PKGS=.common[],.debs[],.ubuntu[],.ubuntu1804[]
ARG BUILD_TOOLS="apt-transport-https software-properties-common ca-certificates curl wget gnupg dpkg-dev genisoimage"
ENV DEBIAN_FRONTEND=noninteractive

WORKDIR package
# dump system package list
RUN dpkg --get-selections | grep -v deinstall | cut -f1 | cut -d ':' -f1 > packages.list
RUN apt update -qq \
&& apt install -y --no-install-recommends $BUILD_TOOLS \
&& add-apt-repository ppa:gluster/glusterfs-7 -y \
&& curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - \
&& echo "deb [arch=$TARGETARCH] https://download.docker.com/linux/ubuntu ${OS_RELEASE} stable" > /etc/apt/sources.list.d/docker.list\
&& apt update -qq

ENV DIR=ubuntu-18.04-amd64-debs
ENV DOCKERVERSION=5:20.10.8~3-0~ubuntu-bionic
ENV PACKAGES="apt-transport-https ca-certificates curl git gnupg-agent software-properties-common sudo openssl openssh-server socat conntrack ebtables ipset docker-ce=${DOCKERVERSION} docker-ce-cli=${DOCKERVERSION} containerd.io chrony ipvsadm nfs-common ceph-common glusterfs-client dnsutils telnet lvm2 keepalived haproxy psmisc tcpdump"
WORKDIR /package
COPY packages.yaml .

RUN mkdir ${DIR} && apt update && apt install curl sudo software-properties-common apt-transport-https -y && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" && \
add-apt-repository ppa:gluster/glusterfs-7 -y && apt update
COPY --from=mikefarah/yq:4.11.1 /usr/bin/yq /usr/bin/yq
RUN yq eval "${PKGS}" packages.yaml >> packages.list \
&& dpkg --get-selections | grep -v deinstall | cut -f1 | cut -d ':' -f1 >> packages.list \
&& sort -u packages.list | xargs apt-get install --yes --reinstall --print-uris | awk -F "'" '{print $2}' | grep -v '^$' | sort -u > packages.urls

ADD download-pkgs.sh ./${DIR}/
RUN mkdir -p ${DIR} \
&& wget -q -x -P ${DIR} -i packages.urls \
&& cd ${DIR} \
&& dpkg-scanpackages ./ /dev/null | gzip -9c > ./Packages.gz

RUN cd ${DIR} && sh download-pkgs.sh && rm -rf download-pkgs.sh && rm -rf errors.txt
RUN genisoimage -r -o ${DIR}.iso ${DIR}

RUN apt install apt-utils dpkg-dev -y && cd ${DIR} && dpkg-scanpackages ./ /dev/null |gzip > ./Packages.gz

RUN apt-get install genisoimage -y && mkisofs -r -o ${DIR}.iso ${DIR}
FROM scratch
COPY --from=ubuntu1804 /package/*.iso /
40 changes: 27 additions & 13 deletions hack/gen-repository-iso/dockerfile.ubuntu2004
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
FROM ubuntu:20.04
FROM ubuntu:20.04 as ubuntu2004
ARG TARGETARCH
ARG OS_RELEASE=focal
ARG DIR=ubuntu-20.04-${TARGETARCH}-debs
ARG PKGS=.common[],.debs[],.ubuntu[],.ubuntu2004[]
ARG BUILD_TOOLS="apt-transport-https software-properties-common ca-certificates curl wget gnupg dpkg-dev genisoimage"
ENV DEBIAN_FRONTEND=noninteractive

WORKDIR package
# dump system package list
RUN dpkg --get-selections | grep -v deinstall | cut -f1 | cut -d ':' -f1 > packages.list
RUN apt update -qq \
&& apt install -y --no-install-recommends $BUILD_TOOLS \
&& add-apt-repository ppa:gluster/glusterfs-7 -y \
&& curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | apt-key add -qq - \
&& echo "deb [arch=$TARGETARCH] https://download.docker.com/linux/ubuntu ${OS_RELEASE} stable" > /etc/apt/sources.list.d/docker.list\
&& apt update -qq

ENV DIR=ubuntu-20.04-amd64-debs
ENV DOCKERVERSION=5:20.10.8~3-0~ubuntu-focal
ENV PACKAGES="apt-transport-https ca-certificates curl git gnupg-agent software-properties-common sudo openssl openssh-server socat conntrack ebtables ipset docker-ce=${DOCKERVERSION} docker-ce-cli=${DOCKERVERSION} containerd.io chrony ipvsadm nfs-common ceph-common glusterfs-client dnsutils telnet lvm2 keepalived haproxy psmisc tcpdump"
WORKDIR /package
COPY packages.yaml .

RUN mkdir ${DIR} && apt update && apt install curl sudo software-properties-common apt-transport-https -y && curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" && \
add-apt-repository ppa:gluster/glusterfs-7 -y && apt update
COPY --from=mikefarah/yq:4.11.1 /usr/bin/yq /usr/bin/yq
RUN yq eval "${PKGS}" packages.yaml >> packages.list \
&& sort -u packages.list | xargs apt-get install --yes --reinstall --print-uris | awk -F "'" '{print $2}' | grep -v '^$' | sort -u > packages.urls

ADD download-pkgs.sh ./${DIR}/
RUN mkdir -p ${DIR} \
&& wget -q -x -P ${DIR} -i packages.urls \
&& cd ${DIR} \
&& dpkg-scanpackages ./ /dev/null | gzip -9c > ./Packages.gz

RUN cd ${DIR} && sh download-pkgs.sh && rm -rf download-pkgs.sh && rm -rf errors.txt
RUN genisoimage -r -o ${DIR}.iso ${DIR}

RUN apt install apt-utils dpkg-dev -y && cd ${DIR} && dpkg-scanpackages ./ /dev/null |gzip > ./Packages.gz

RUN apt-get install genisoimage -y && mkisofs -r -o ${DIR}.iso ${DIR}
FROM scratch
COPY --from=ubuntu2004 /package/*.iso /
Loading

0 comments on commit 0fa9eda

Please sign in to comment.